Auth0 Home Blog Docs

custom social connections and refresh_token

azure-ad
custom-social-connec
refresh_token

#1

We are using a custom social connection for an Azure AD oAuth flow, we use the custom connection so we can do some property mapping during the flow. We are trying to not only get the access_token but also the refresh_token.

The method signature for Fetch User Profile is function(accessToken, ctx, cb).

Access token is available as part of the method passed in parameters but the refresh_token is nowhere to be found, including in the context.

Additional information: we are requesting the scopes openid offline_access.

Does anyone know how or if it is even possible to get the refresh_token through a custom social connection and the fetch user profile script?


#2

Based on the documentation the ability to obtain a refresh token issued during an authentication flow processed through an Auth0 tenant/domain is available only for a subset of the default social provider connections and for custom OAuth 2.0 connections. You did not explicitly mentioned the OAuth version of your connection, but I believe Azure AD would be 2.0 so obtaining the refresh token should be feasible.

However, the method to obtain the refresh token as mentioned in the linked documentation is to perform an Auth0 Management API call with an access token containing specific scopes. In conclusion, the refresh token would not be available as part of the fetch user profile script. Having said that, this should not be an issue because when that script is invoked the access token was just issued and as such is still valid. You should perform the process described in the documentation and update your question if you still do not obtain the refresh token.


#3