I’m using the AuthenticationApiClient C# lib to craft a Lock login for a Google account:
var client = new AuthenticationApiClient(new Uri($"https://{_configuration["Authentication:Auth0:Domain"]}"));
var urlb = client.BuildAuthorizationUrl();
var uri = urlb.WithClient(_configuration["Authentication:Auth0:ClientId"])
.WithRedirectUrl(GetBaseUri() + "Organization/AuthorizeGAFinish?id=" + id + "&returnAction=" + returnAction)
.WithResponseMode(AuthorizationResponseMode.FormPost)
.WithResponseType(new AuthorizationResponseType[] { AuthorizationResponseType.IdToken, AuthorizationResponseType.Code, AuthorizationResponseType.Token })
.WithNonce("1234")
.WithAudience(_configuration["Authentication:Auth0:Audience"])
//.WithConnection("google-oauth2")
.WithScope($"openid {Uri.EscapeUriString("https://www.googleapis.com/auth/analytics.readonly")}")
//.WithValue("access_type","offline")
.Build();
Later on I get the access token with:
var mgmtToken = await GenerateManagementApiToken();
var client = new ManagementApiClient(mgmtToken, new Uri(_configuration[“Authentication:Auth0:Audience”]));
var auth0User = await client.Users.GetAsync(userId);
return auth0User.Identities[0].AccessToken;
However I need the refresh token as I need to do this offline. However Identities[0].RefreshToken
is always null.
I have tried forcing Lock to provide access_type=offline to Google by modifying the Auth0 hosted page with:
var authParams = config.internalOptions;
authParams.access_type = ‘offline’;
authParams.approval_prompt = ‘force’;
var lock = new Auth0Lock(config.clientID, config.auth0Domain, {
auth: {
redirectUrl: config.callbackURL,
responseType: (config.internalOptions || {}).response_type ||
(config.callbackOnLocationHash ? ‘token’ : ‘code’),
params: authParams
//params: config.internalOptions
},
Still doesn’t work. How do I get Auth0 to store the refresh token?