0

So i am trying to make this get request to the GMAIL message endpoint:

https://www.googleapis.com/gmail/v1/users/test%40email.com/messages?q=from%3Asender%40test.com+is%3Aread&key=MYKEYHERE

But I keep getting a 401 error about login.

 "code": 401,
    "message": "Login Required"

I already authenticated the user with: var SCOPES = ['https://mail.google.com/'];

I know this is an Auth issue but dont know how to solve it. Am I suppose to autheticate the user ever time I need to use the api? What do I do?

How can I make this get request from the app that is authroized?

I have it working in the google testing tool here

*new to oauth2 and appreciate your help. thanks

1

1 Answer 1

1

once you have an access token back from your oauth2 login. you need to use access_token not key. Key is use for accessing public APIs.

https://www.googleapis.com/gmail/v1/users/test%40email.com/messages?q=from%3Asender%40test.com+is%3Aread&access_token=YourAccessTokenHere
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.