OAuth redirection and Client login #652
-
|
Is there a way to use this project with the OAuth log in page redirect flow? Client login requires session string or name and password, and you won't get either session string or password if you log in using the OAuth flow. I have several enpoints built using this SDK and I am looking forward to avoid rewriting them all to use access and refresh tokens. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
Hi, I think @zzstoatzz could help you here. So pinging |
Beta Was this translation helpful? Give feedback.
-
|
hi @fpstidston - i have oauth implemented in my fork here, i (still) need to contribute that upstream here 😓 if you install from the fork, you can do something like this with from atproto_oauth import OAuthClient
client = OAuthClient(
client_id="https://your-app.com/client-metadata.json",
redirect_uri="https://your-app.com/callback",
scope="atproto repo:...",
state_store=your_state_store,
session_store=your_session_store,
)
# start flow
auth_url, state = await client.start_authorization(handle)
# redirect user to auth_url
# handle callback
oauth_session = await client.handle_callback(code, state, iss)
# oauth_session has: .did, .handle, .access_token, .refresh_token, .dpop_private_key
# make requests
response = await client.make_authenticated_request(
session=oauth_session,
method="POST",
url=f"{oauth_session.pds_url}/xrpc/com.atproto.repo.createRecord",
json={...},
)
# refresh when needed
refreshed = await client.refresh_session(oauth_session)store |
Beta Was this translation helpful? Give feedback.
-
|
I'm currently advertising to pay for help integrating this PR into my portfolio project |
Beta Was this translation helpful? Give feedback.
hi @fpstidston - i have oauth implemented in my fork here, i (still) need to contribute that upstream here 😓
if you install from the fork, you can do something like this with
OAuthClient: