0

I tried using this from Google's page (the xxx would be the key I got from https://console.developers.google.com/ - Web Client client OAuthID):

https://accounts.google.com/o/oauth2/v2/auth?
 scope=email%20profile&
 state=%2Fprofile&
 redirect_uri=https%3A%2F%2Foauth2.example.com%2Foauthcallback&
 response_type=token&
 client_id=xxx

I don't know what to put for redirect_uri, as well as scope and state. I wanted to access a spreadsheet which I could read and write to. Reading seems to be easy, I could just make a GET request and read but writing needs a token. I tried playing with it on OAuth 2.0 Playground. I clicked some buttons and got a token then I tried it with Postman and it works, I could write to the spreadsheet. The only problem is the token expires and I'm not sure how to request a token each time I wish to write. Or is there a way to get a token that doesn't expire? Please let me know if there's anything I could provide. I've been trying a lot of things for a few days a can't seem to get it to work. I also couldn't find anything that could help me.

Vinz
  • 183
  • 1
  • 1
  • 9

1 Answers1

0

How to access spreadsheet API?

First, check this documentation on how to properly authenticate your project with Google Sheets API, or this link that shows the steps on how to access Google API using OAuth 2. It includes here on how to refresh the access token.

What to put for redirect_uri, as well as scope and state?

If you don't know what to put for redirect_uri, scope and state, you can understand the meaning of each one and the value that you need to pass on them by checking the Forming the URL under the OAuth 2.0 for Client-side Web Applications.

Is there a way to get a token that doesn't expire?

I think there is no token that doesn't expire. It is better to make your token expired because it will serve as your security measure. Let say, if your application is hacked, the attacker will only have a limited time to your short-lived access token and no way to reproduce a new token.

For more information, check these threads:

Community
  • 1
  • 1
KENdi
  • 7,205
  • 2
  • 14
  • 26
  • I got the URL above from the "Forming the URL" page that you posted but I can't seem to make it work. It always gives me error. I'm not sure what I'm doing wrong here. – Vinz Oct 01 '16 at 21:47
  • I tried again and it redirects me to sign in page. Shouldn't it skip this page? – Vinz Oct 03 '16 at 00:39
  • sign in? are you not sign in using your google account? – KENdi Oct 03 '16 at 02:19
  • I am. I'm doing a post request using my client ID then it returns a sign in page. The sign in page can't be used at all. – Vinz Oct 04 '16 at 21:07