question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scopes not working for Google on Android

See original GitHub issue

Hi there,

I’m trying to pass scope to Google as follows:

        manager.authorize('google', {scopes: 'profile email'})
            .then(resp => this.cleanLoginData('google',resp.response))
            .catch(err => console.log('There was an error'))

However, that doesn’t seem to provide the email when I try to call manager.makeRequest(‘google’,googleUrl) to https://www.googleapis.com/oauth2/v1/userinfo?alt=json.

The solution was to go into android/src/main/java/io/fullstack/oauth/OAuthManagerProviders.java and change line 101 to String scope = “profile email”;

Is this a known issue, or am I doing something wrong? I notice that a lot of the language in the java files refers to “scope” rather than “scopes” (with the “s”), as passed in the above authorize code snippet. Could this be the issue?

Thanks! Jason

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:26 (22 by maintainers)

github_iconTop GitHub Comments

2reactions
LaurelOlsoncommented, Jan 3, 2017

Try including scope in the config constant along with the client_id and client_secret instead of in the options hash like so:

    const config =  {
      github: {
        client_id: Platform.OS === 'ios' ? Config.GITHUB_CLIENT_ID : Config.GITHUB_CLIENT_ID_ANDROID,
        client_secret: Platform.OS === 'ios' ? Config.GITHUB_CLIENT_SECRET : Config.GITHUB_CLIENT_SECRET_ANDROID,
        scope: 'user'
      }
    }
0reactions
BricePissardcommented, Feb 9, 2017

Maybe this could help, setting the credential’s scopes into fully qualified URL separated by ‘+’ will also 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'
  }
}

But BTW i have another error that appears after the scopes’ hand check, cf: #61

is anyone is receiving the same error, in XCode logs: { status: ‘error’, msg: ‘The operation couldn’t be completed. (NSURLErrorDomain error -1012.)’ }

Read more comments on GitHub >

github_iconTop Results From Across the Web

Requesting Additional Scopes | Authentication
Whenever a user performs an action that requires a scope that isn't requested at sign-in, call GoogleSignIn.hasPermissions to check if the ...
Read more >
Cannot set scope Google sign in on Android - Stack Overflow
I use Google API for signin on Android app ...
Read more >
Control which third-party & internal apps access Google ...
You use settings in the Google Admin console to govern access to Goo. ... Some apps use OAuth 2.0 scopes—a mechanism to limit...
Read more >
DevicePolicyManager - Android Developers
An ArrayList<String> corresponding to the delegation scopes given to an app in the ... Returns true if the caller is running on a...
Read more >
Shot Scope - Apps on Google Play
The official companion app for Shot Scope GPS devices, including V3, H4, G3 and V2, is available to download on Android devices. The...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found