goauthentik / authentik

The authentication glue you need.
https://goauthentik.io
Other
12.74k stars 850 forks source link

Store & Refresh Social Login Tokens & Pass them to final apps #3941

Open tieb62 opened 1 year ago

tieb62 commented 1 year ago

My instance of authentik accepts login via Microsoft & Discord

I want to use Discord & Microsoft Tokens in my final app

For example to make the user join Discord server (of course the corresponding scope is added to authentik)

If authentik could store tokens (& refresh tokens & expiration date) even if it does not refresh them automatically, if the final app can access those 3 values, it can use the token if it's valid, and refresh it if not (if the refreshing must be done by the final app, an authentik endpoint must be set up for the app to push back to authentik the refreshed token and the new expiration & refresh token

TL;DR;

tieb62 commented 1 year ago

Bump

oytuntez commented 4 months ago

Do these tables store actual oauth2 tokens from the provider?

authentik_providers_oauth2_accesstoken authentik_providers_oauth2_authorizationcode authentik_providers_oauth2_refreshtoken

I am still trying to use oauth2 tokens from authentik.

BeryJu commented 4 months ago

you can reference https://docs.goauthentik.io/integrations/sources/discord/#checking-for-membership-of-a-discord-guild to see how the access/refresh tokens can be accessed through the flow context

@oytuntez those tables are used by the OAuth2 Provider, not the source, and are for tokens generated by authentik

oytuntez commented 4 months ago

That's very useful! I'll build a machine-only flow that we can even call in a later time to fetch tokens. Thank you!

I also figured connecting non-OpenID oAuth2 providers... it feels like I am getting a hold of using Authentik as an integration authentication platform.

oytuntez commented 4 months ago

I believe this issue can be marked as solved.