-
Notifications
You must be signed in to change notification settings - Fork 493
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
Update parameters-whitelist.js to include access_type and approval_prompt #566
Comments
Hi, Can you give us some background on why you need those? None of them are standard OAuth/OIDC parameters, and we don't want customers to send parameters to /authorize that are not in the standard. approval_prompt seems to have been replaced with the prompt=none: The approach we'd want to take here is to understand the use case and have our server do the right mapping between standard parameters to /authorize and whatever upstream identity providers like google expect. For example, access_type is used for offline access, and the OIDC standard says it should be set in the 'scope' parameter. Thanks, Andres |
Hi @aaguiarz , definitely. My application gives users the option to link their google accounts. When they link their accounts, my app makes a call to the
This will "force" google to return me a refresh token which my app needs. Without setting access_type and approval_prompt, google does not return me the required refresh token (at least not on subsequent auth). I hope the above provides more context but please let me know if you require further information. More details: I just tried with
but the refresh token is still not being returned. P.S: I seem to recall that Auth0 dashboard had an offline permission for Google connections before but I cant find it anymore. Maybe re-enabling that feature there instead is an option? Regards, |
I just opened a pull request #760 |
Hi! I'm sorry about the copy/paste message, but I'm cleaning up some stale issues. 🗑 |
I just tried to get a On the frontend I'm using import auth0 from 'auth0-js'
const auth0 = new auth0.WebAuth({
domain: 'https://example.auth0.com',
clientID: 'my_client_id',
redirectUri: 'https://example.com/handle-auth',
audience: 'https://example.auth0.com/api/v2/',
responseType: 'id_token token',
scope: 'openid profile email read:current_user create:current_user_metadata update:current_user_metadata',
accessType: 'offline' // <-- this is supposed to trigger refresh token retrieval, I think
}) My backend API uses a separate machine-to-machine Auth0 app that has access to the Management API with the following scopes:
The backend client is configured and queries Auth0 as follows: // config
const mc = require('auth0').ManagementClient
const client = new mc({
domain: 'example.auth0.com',
clientId: 'my_client_id',
clientSecret: 'my_client_secret'
})
// queries, e.g.
client.getUsersByEmail('[email protected]')
client.getUser({ id: 'google-oauth2|1234567890' }) I've also tried using the API Explorer but no matter which method I try, the {
access_token: "a_valid_access_token_12341341234",
connection: "google-oauth2",
expires_in: 3600,
isSocial: true,
provider: "google-oauth2",
user_id: "1234567890"
} No refresh token. 😢 Am I missing something or doing something wrong? The reason this is important is that, as noted above, the Google API Does this make sense? |
@morphatic It's been a while since I last touched this but iirc, specifying |
@johnlim Thanks for the feedback! It took a couple of weeks for this to get back to the top of my "todo" list. I was finally able to get a As you indicated, you only get a
I ended up writing a rule that will store the /**
* Store the user's Google API tokens in app_metadata.
*/
function (user, context, callback) {
// get the full Google identity record
const identity = user.identities.filter(i => i.provider === 'google-oauth2')[0];
// abort if there is no Google identity
if (!identity) callback(null, user, context);
// otherwise, make sure app_metadata is defined
user.app_metadata = user.app_metadata || {};
// make sure that the "google" property is defined
user.app_metadata.google = user.app_metadata.google || {};
// if we were passed a refresh token... (only happens on 1st login?)
if (identity.refresh_token) {
// add it to the metadata
user.app_metadata.google.refresh_token = identity.refresh_token;
}
// update the access token in the metadata (should be passed every login)
user.app_metadata.google.access_token = identity.access_token;
// update the app_metadata in the Auth0 database
auth0.users.updateAppMetadata(user.user_id, user.app_metadata)
.then(() => {
// move along...
callback(null, user, context);
})
.catch(err => {
// ruh-roh! couldn't update app_metadata
callback(err);
});
} 🚨 BAD IDEA™ Do NOT Do ThisThis works as far as getting access to the token, but this is a BAD IDEA since it will end up sending the Better Idea, but not 100% reliableAs an alternative, instead of storing the Of course, all of these issues would go away if there were some way to get an updated Google Any thoughts? |
Okay, I think I've come up with a solution for this. I wrote a blog post about it. Feedback is welcome! |
Hi,
When calling the authorize endpoint with access_type and approval_prompt, the following warning is printed to console
Following parameters are not allowed on the `/authorize` endpoint: [access_type, approval_prompt]
.However, these are valid parameters for connections such as google-oauth2. I'd be happy to update parameters-whitelist.js and issue a pull request but wanted to run this by you guys first.
Cheers,
John
The text was updated successfully, but these errors were encountered: