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

Nck
  • 1
  • Maybe this can help you: http://stackoverflow.com/a/40705533/2972087 It's a working configuration of Gmail API for Angular2 – kris_IV Nov 22 '16 at 18:14

1 Answers1

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
Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449