snipsco / Postal

A Swift framework for working with emails
MIT License
652 stars 81 forks source link

Gmail OAuth2 error #50

Closed likedan closed 7 years ago

likedan commented 7 years ago

I've implemented Gmail Outh2 and pass the access token in. It got this error: error: login("Invalid credentials (Failure)")

jeremiegirault commented 7 years ago

Have you set the correct scope as in https://github.com/snipsco/Postal/blob/master/Documentation/ProviderQuirks.md#gmail ? The scope is https://mail.google.com/

likedan commented 7 years ago

Thanks for the quick reply! Where should I set the scope? An example?

jeremiegirault commented 7 years ago

You should set the scope when you present the oauth flow to the user (in a scope GET parameter usually).

likedan commented 7 years ago

Emmm, I'm not sure if we're on the same page, but I've done the google Oauth2 flow and successfully retrieved the access token, but can connect with postal. I was doing let postal = Postal(configuration: .gmail(login: GIDSignIn.sharedInstance().currentUser.profile.email, password: PasswordType.accessToken(access_token)))

Kedan

发自我的 iPhone

在 2017年2月16日,08:29,Jérémie Girault notifications@github.com 写道:

You should set the scope when you present the oauth flow to the user (in a scope GET parameter usually).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

jeremiegirault commented 7 years ago

okay, what scope have you used during oauth flow ?

ref.: https://developers.google.com/identity/protocols/OAuth2

Step 2: Obtain an access token from the Google Authorization Server. A variable parameter called scope controls the set of resources and operations that an access token permits. During the access-token request, your application sends one or more values in the scope parameter.

Did you set the scope to https://mail.google.com/ ?

likedan commented 7 years ago

Got it to work! Accidentally figured out where to add the scope.

Thanks for the assistance,

Kedan

On Feb 16, 2017, at 8:36 AM, Jérémie Girault notifications@github.com wrote:

okay, what scope have you used during oauth flow ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/snipsco/Postal/issues/50#issuecomment-280383719, or mute the thread https://github.com/notifications/unsubscribe-auth/AIZG05kz9Ywh4STLM8vJdP04u99Qtjqiks5rdHsFgaJpZM4MChPV.