-
Notifications
You must be signed in to change notification settings - Fork 214
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
some requested scopes were invalid #61
Comments
Maybe setting the credential's scopes into fully qualified URL separated by '+' will work for you: google: {
...,
scopes: {
'https://www.googleapis.com/auth/plus.login+' +
'https://www.googleapis.com/auth/calendar+' +
'https://www.googleapis.com/auth/calendar.readonly+' +
'https://www.googleapis.com/auth/contacts+' +
'https://www.googleapis.com/auth/contacts.readonly+' +
'https://www.googleapis.com/auth/userinfo.profile+' +
'https://www.googleapis.com/auth/userinfo.email+' +
'https://www.googleapis.com/auth/user.addresses.read+' +
'https://www.googleapis.com/auth/user.birthday.read+' +
'https://www.googleapis.com/auth/user.emails.read+' +
'https://www.googleapis.com/auth/user.phonenumbers.read'
}
} In my case I have another error appearing after validating the scopes hand check. with: OAuth.authorize( 'google', { scopes: 'profile+email' } )
.then( ( oauthCredit:Object ):void => {
console.log( oauthCredit ); // <-- status 'ok', the token is received.
const token:string = oauthCredit.response.credentials.accessToken;
const url:string = 'https://www.googleapis.com/oauth2/v1/userinfo';
//const url:string = 'https://www.googleapis.com/plus/v1/people/me'; // <-- either with this WS and without parameters
OAuth.makeRequest( 'google', url, {
method : 'get',
params : {
alt : 'json',
access_token : token
}
}
)
.then( ( rep:Object ):void => {
console.log( rep ); // <-- crash before arriving here
});
}); Everything works fine on iOS simulator but on the device I've got in XCode logs: Is anyone facing the same issue?Ok I fixed that issue, the : NSURLErrorDomain error -1012 mean error 401, when the scopes get updates (one scope more or one scope less) the token is invalidated, it needs to be reseted and assigned again. |
Couldn't make this work on android, manager.authorize('google', {scopes: 'email,profile'})
.then(resp => console.log(resp))
.catch(err => console.log(err)); |
Try {scopes: 'email profile'} i.e. without the comma. I've updated the README to correct this
Martin
…Sent from my iPhone
On 10 Feb 2017, at 11:35, EL YOUBI ***@***.***> wrote:
Couldn't make this work on android, invalid_scope error
manager.authorize('google', {scopes: 'email,profile'})
.then(resp => console.log(resp))
.catch(err => console.log(err));
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
For me it works with {scopes: 'email+profile'}. |
{scopes: 'email profile'} didn't work, {scopes: 'email+profile'} worked. Thanks @buskerone |
Submitted #121 for this issue |
neither {scopes: 'email+profile'} nor {scopes: 'email,profile'} nor {scopes: 'email profile'} worked for me. Though doing just {scopes: 'email'} or {scopes: 'profile'} did work for me. |
I am getting this error too, no matter what I use as a delimiter. Single scopes work fine but that is no help to me. |
Not sure if someone has a better solution or a newer fork, but here's what seemed to work for me: TL;DR For android use the let config
let scopes
if (Platform.OS === 'ios') {
config = {
google: {
client_id: '...',
callback_url: '...',
},
}
scopes = 'openid+email+profile'
} else if (Platform.OS === 'android') {
config = {
google: {
client_id: '...',
client_secret: '...',
callback_url: 'http://localhost/google',
rawScopes: 'true',
},
}
scopes = 'openid email profile'
}
manager.configure(config)
// ...
manager.authorize('google', { scopes }) |
@maxlang The error on Android while using |
@haotangio I did originally, but worked around it using the code above. Did you try using As for version, I'm actually using https://github.com/exentrich/react-native-oauth to work around some other issues I was having, but the android code should be the same I think. |
@maxlang I did try |
Ok, it looks like the change to support rawScopes was never officially "released" as a version. Try the following: npm uninstall --save react-native-ouath
npm install --save fullstackreact/react-native-oauth This should update you to master. Make sure |
@maxlang Thank you so much for your information. I will try soon. I guess it will work. |
Leaving it here for the Google Search ™️ users: https://developers.google.com/identity/protocols/oauth2/scopes Make sure you have the right scopes enabled in the project. For e.g., to get |
you can also use the scopes in this way. |
The README says:
manager.authorize('google', {scopes: 'profile,email'}
but this gives the error 'some requested scopes were invalid'
using the following works so I will raise a PR on the README
manager.authorize('google', {scopes: 'profile email'}
The text was updated successfully, but these errors were encountered: