tryingToLearn
tryingToLearn

Reputation: 11663

Error code 400 on generating OAuth 2 SASL string

I have generated the following SASL string FOR OAuth 2:

[email protected]^Aauth=Bearer ya29.AHES6ZTtYOu0NR0vAYbrvKZNcHJPuZEpr4Hk3W3dXcXFQ88^A^A

Then i encoded it and sent the encoded string like this:

MSB AUTHENTICATE XOAUTH2 encoded string

But i get error response as:

{"status":"400","schemes":"Bearer","scope":"https://mail.google.com/"}

What does this error mean and how can i correct it?

Upvotes: 1

Views: 4173

Answers (2)

tryingToLearn
tryingToLearn

Reputation: 11663

I finally figured it out. In my case, the Gmail scope("https://mail.google.com/") was missing, from the token generation process. It works fine now.

EDIT:

(Including comment from @ohmyfromage:)

When you call generateAuthUrl, you need to pass an object with an array scope of strings as the scopes, and one of those strings is "https://mail.google.com/"

Upvotes: 6

fmsf
fmsf

Reputation: 37177

+1 to akshay for self answering.

This can also happen if you are using an expired token. If that is the case, just re authenticate your user and use the new token.

Upvotes: 1

Related Questions