cjrasmussen / BlueskyApi

Simple helper for interacting with the Bluesky API/AT protocol
MIT License
27 stars 5 forks source link

Error exception on creating session #6

Closed japafrite closed 11 months ago

japafrite commented 11 months ago

Hey, On creating session I have an error exception on line 26 in case of rate limit 🙃, data returned does not have did property. Properties are : +"error": "RateLimitExceeded" +"message": "Rate Limit Exceeded" How can we manage this ?

cjrasmussen commented 11 months ago

Thanks for the heads-up. v1.1.2 throws a RuntimeException when the session can't be established. You'll be able to catch that exception in your code.

colin-walker commented 11 months ago

@japafrite The createSession endpoint has the following limits:

So if you're exceeding this you'll get rate limited (generally for 24 hours) and would instead need to refresh an existing session using com.atproto.server.refreshSession

What I'm doing is saving the refresh token ($data->refreshJwt) to a file. Then each time I connect I check for the file and use the token to refresh any open session. You can see it in my fork.

cjrasmussen commented 11 months ago

Very good point, @colin-walker. While this library now throws an exception when you hit your rate limit, it doesn't do help prevent you from hitting that rate limit. I'm currently working on v2.0.0 which takes advantage of com.atproto.server.refreshSession (though in a different way than your fork does).

colin-walker commented 11 months ago

@cjrasmussen I look forward to seeing how you do it.