Skip to content
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

Getting authenticated user's data from oauth provider #7344

Open
samyarkd opened this issue May 14, 2024 · 4 comments
Open

Getting authenticated user's data from oauth provider #7344

samyarkd opened this issue May 14, 2024 · 4 comments
Labels
auth Issues with the auth extension documentation dx

Comments

@samyarkd
Copy link

I could not find a way to get the data related to the authenticated user from the oAuth provider such as user name, email or profile picture.

@scotttrinh
Copy link
Contributor

We haven't documented this well, but in the final callback after the PKCE flow, when we give you the auth token and identity ID, we also give you back whatever the OAuth provider gave us under the keys: provider_token and provider_refresh_token which you can use to make authenticated calls to the identity provider.

I'll leave this ticket open while we add more guidance in the documentation for this.

@scotttrinh scotttrinh added auth Issues with the auth extension documentation dx labels May 14, 2024
@samyarkd
Copy link
Author

@scotttrinh is there any GitHub repo that has already done this? i'd very much appreciate it because i couldn't find one.

@scotttrinh
Copy link
Contributor

We have a documentation PR that will land shortly to show how to do this. You can see it here: #7354 or wait for a bit until it lands in the guides itself.

@samyarkd
Copy link
Author

thank you,

You point me in the right direction and i found out this is how you can achieve it with GitHub:

    const userDataReq = await fetch("https://api.github.com/user", {
        headers: {
          Authorization: `token ${tokenData.provider_token}`,
        },
      });
      const userData = (await userDataReq.json()) as GithubUserDataRes;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth Issues with the auth extension documentation dx
Projects
None yet
Development

No branches or pull requests

2 participants