-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issues creating a Bluesky post #15
Comments
You need to specify the credential when you post, unless you set a PSDefaultParameterValue. Try again and include the -Credential parameter. |
I see that now. You can run |
Let's confirm that you are running on a Windows platform. |
Ok. That's a good sign. I don't think the Mac should make a difference, but now I know I should at least test from Linux. Let's see if the information stream gives us any more data. Re-run the post command and add Assuming the command fails, run |
PS /Users/matthew/Documents/Scripting> $iv.MessageData | Format-List |
That is what I would expect to see up until the error. I'm assuming the repo value matches your credential username including casing. The error message sounds like a DNS-type problem, but that doesn't make sense since the other commands work. I am puzzled and don't have an immediate solution. I'll have to think about how else to troubleshoot. |
Yes very odd but I was wondering if it might be DNS. My account is only a few days old. Would using my non custom domain Bluesky username be something to try potentially? |
I'm using a custom domain name without issue. I was able to post from Linux. You've posted content so that shouldn't be an issue. Let's try another approach. #use whatever variable name you are using for the credential object.
$repo = $cred.UserName
$pw = $cred.GetNetworkCredential().Password
$PDSHOST = 'https://bsky.social'
$headers = @{
'Content-Type' = 'application/json'
}
$body = @{
'identifier' = $user
'password' = $pw
} | ConvertTo-Json
$s = Invoke-RestMethod -Uri "$PDSHOST/xrpc/com.atproto.server.createSession" -Method Post -Headers $headers -Body $body
$token = $s.accessJwt
$headers = @{
'Authorization' = "Bearer $token"
'Content-Type' = 'application/json'
}
$url = "$PDSHost/xrpc/com.atproto.repo.listRecords?repo=$repo&collection=app.bsky.feed.post&limit=5"
$r = Invoke-RestMethod -Uri $url -Method Get -Headers $headers
#this should return the last 5 posts
$r.records.value Maybe this will validate the repo name. |
I don't think you finished setting up the verification for your custom name. https://bsky-debug.app/handle?handle=%40matthewrstreeter.com |
Never mind. I screwed that up. |
Also run:
|
I'm back at my desk now. I'll give the code block a shot in a moment. Here is the (Get-BskySession).diddoc output: @context : {https://www.w3.org/ns/did/v1, https://w3id.org/security/multikey/v1, |
The session looks right, which shouldn't be a surprise since most of the module commands work. |
A Bluesky user confirmed no problems using a Mac so the issue is something about your account. I think this means creating the credential with your pre-custom name. First, try to get your profile with the old name. I'm not sure it will work. |
That's the same problem. The repo is your username, which is getting pulled from the credential. I don't understand why the repo endpoint can't find the name. |
I stripped everything down to the bare essentials in this script file. Param(
[PSCredential]$Credential
)
$message = "This is a debug test Bluesky message sent from VSCode."
$user = $credential.UserName
$pw = $credential.GetNetworkCredential().Password
$PDSHOST = 'https://bsky.social'
#create a session
$headers = @{'Content-Type' = 'application/json'}
$body = @{
'identifier' = $user
'password' = $pw
} | ConvertTo-Json
$s = Invoke-RestMethod -Uri "$PDSHOST/xrpc/com.atproto.server.createSession" -Method Post -Headers $headers -Body $body
$headers.Add('Authorization', "Bearer $($s.accessJwt)")
$apiUrl = "$PDSHOST/xrpc/com.atproto.repo.createRecord"
$record = [ordered]@{
'$type' = 'app.bsky.feed.post'
text = $Message
createdAt = (Get-Date -Format 'o')
}
$body = @{
repo = $Credential.UserName
collection = 'app.bsky.feed.post'
record = $record
} | ConvertTo-Json -Depth 7
Invoke-RestMethod -Uri $apiUrl -Method Post -Headers $headers -Body $body -Verbose Save this as a .ps1 file. Then run |
I posted before seeing your recent post. I'll give that a try. Store credential in SecretManagement$username = 'matthewrstreeter.com' |
That is what I would expect and since the other commands work, I didn't think that should be a problem. |
I initially had the same issue.
Running 7.4.6 on MacOS 14.7.1. Instead of using the email account I use to login to Bluesky, I used my I can run more commands later tonight if needed. Might be worth mentioning that an entity could use subdomains for multiple people using the |
@thedavecarroll When you define your credential for use with this module, what do you set for the username? |
I used:
|
This helped me. |
I tried the did:xyzabc value for the repo and that was the trick (at least from my Windows machine so far) @thedavecarroll thanks for posting that the DID value worked for you. |
I think we've narrowed down the problem is OS-related. The module works fine on Windows. And it mostly works on a Mac except for posting a message. This is going to take some external research. |
Does the Mac do any sort of proxy filtering? |
It’s actually a brand new Mac Mini (yay me haha). Nothing customized for network or routing on this system either.
I can try from my work Mac too just to see if the results are the same.
…________________________________
From: Jeff Hicks ***@***.***>
Sent: Thursday, November 14, 2024 8:49:07 AM
To: jdhitsolutions/PSBluesky ***@***.***>
Cc: Matthew Streeter ***@***.***>; Manual ***@***.***>
Subject: Re: [jdhitsolutions/PSBluesky] Issues creating a Bluesky post (Issue #15)
EXTERNAL
________________________________
I can see your test profile.
image.png (view on web)<https://github.com/user-attachments/assets/84866080-337b-40eb-aa6c-9bb76ad3ac37>
And search for it in the browser
image.png (view on web)<https://github.com/user-attachments/assets/cf47550d-7633-4237-8747-31c7190c7982>
Which indicates there is nothing wrong with the account itself. Only when the Mac attempts to resolve and validate the account name.
—
Reply to this email directly, view it on GitHub<#15 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/BDAUCU6FUDLGOJMNBQJB2V32ASZ6HAVCNFSM6AAAAABRSSWZVCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINZWGU2TAMBWGA>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Well... I was just successful posting from my work Mac. I'm wondering if the install of the module on my personal Mac went wonky or I happened to mess that up. |
Curious. I'm assuming the same version of PowerShell is installed on both. Was your work Mac on the same network as the Mac Mini? I can't imagine what you would have messed up installing the module. |
This is so strange. No luck posting from personal Mac after a fresh uninstall and reinstall of the module either. Both are on 7.4.6 core. My personal Mac is a new M4 Mac Mini, my work Mac is a M1 MacBook Pro. Same network too. Wired on my home network. |
That is odd and frustrating because we're running out of things to test. I'm assuming PowerShell commands and other modules work just fine on the mini. |
Can you do any type of network capture like Wireshark to compare the |
Is the Mac Mini using a VPN or is private relay configured? |
I can post to my test account from my Mac Mini actually. It seems to be specific to my username as I cannot seem to use the New-BskyPost cmdlet for my 'matthewrstreeter.com' handle but I can post to my 'matthew-test.bsky.social' handle from any of my Macs. Nothing on the Mac Mini for VPN or Private Relay either. Just rebooted too just be sure there 😄 |
I'm curious if the debug web page shows different results. I'm expecting if you open |
Here's another test script. Param(
[PSCredential]$Credential,
[string]$Repo = "jdhitsolutions.com"
)
$user = $credential.UserName
$pw = $credential.GetNetworkCredential().Password
$PDSHOST = 'https://bsky.social'
#create a session
$headers = @{'Content-Type' = 'application/json' }
$body = @{
'identifier' = $user
'password' = $pw
} | ConvertTo-Json
$s = Invoke-RestMethod -Uri "$PDSHOST/xrpc/com.atproto.server.createSession" -Method Post -Headers $headers -Body $body
$headers.Add('Authorization', "Bearer $($s.accessJwt)")
$apiUrl = "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$repo&collection=app.bsky.feed.post&limit=5"
$splat = @{
Uri = $apiUrl
Method = 'Get'
Headers = $headers
ErrorAction = 'Stop'
OutVariable = 'global:ov'
ResponseHeadersVariable = 'global:rh'
Verbose = $true
}
$r = Invoke-RestMethod @splat
$r.records.value | Select CreatedAt,Text If I use your test name, this works as expected. But it fails with your other account name. However, I can get your DiD ( did:plc:6sa7bzdm7behw6k45oaprg7f) from your profile, and that WILL work. There is something about the |
Try my test repo list script on both systems testing both account names and the DID of your DNS account and see if you get the same results I do. |
I'm getting some guidance from the Bluesky developer's Discord. I may need to revise my code to use the DiD instead of an account handle. |
Holding off on any more testing until Bluesky's network issues are resolved. |
Did I break everything haha? 😆 /s |
I made a major change to the posting command in the latest version. Update to v1.3.0 and let's see if this makes a difference. |
Excellent. It appears some API endpoints don't work well with handles so I revised commands to use the accounts DID where it was supported. |
Hey Jeff! I reached out on Bluesky about this but I'm trying to get things setup with your module. I am having trouble getting the create post function to work for me however.
I'm able to from Get-BskyProfile, Get-BskyFollowers, etc. without an issue.
The text was updated successfully, but these errors were encountered: