getUserOauthAccessToken()
Retrieve the corresponding OAuth access token for a user that has previously authenticated with a particular OAuth provider.
function getUserOauthAccessToken(
  userId: string,
  provider: `${OAuthProvider}`,
): Promise<OauthAccessToken[]>- Name
- userId
- Type
- string
- Description
- The ID of the user to retrieve the OAuth access token for. 
 
- Name
- provider
- Type
- ${OAuthProvider}
- Description
- The OAuth provider to retrieve the access token for. If using a custom OAuth provider, prefix the provider name with - custom_(e.g.,- custom_foo).
 
const userId = 'user_123'
const provider = 'google'
const response = await clerkClient.users.getUserOauthAccessToken(userId, provider)You can also explore the example that demonstrates how this method retrieves a social provider's OAuth access token, enabling access to user data from both the provider and Clerk.
Backend API (BAPI) endpoint
This method in the SDK is a wrapper around the BAPI endpoint GET/users/{user_id}/oauth_access_tokens/{provider}. See the BAPI reference for more information.
Feedback
Last updated on