0

I have seen google apps script's tutorial to migrate from oAuthConfig to oauth1 here But what if I have the access tokens with me already? I checked the oauth1 library code here and could not find a way to include access token here.

Is there any alternative way? Also note that I have 4 things with me: Consumer Key, Consumer Secret, Token and Token secret.(Note: I have 2 things in access token, not only a single token).

rahulserver
  • 10,411
  • 24
  • 90
  • 164
  • @ZigMandel where did you find oauth2 in any of the links I have shared? – rahulserver Jul 31 '15 at 05:34
  • removed comment. sorry assumed you were using oauth2 as oauth1 is no longer supported in google apis (but i guess you can use it for other non google services) – Zig Mandel Jul 31 '15 at 11:58

1 Answers1

0

As mentioned here(read the Warning on that link), OAuth1 was shut down on April 20 this year. So I am assuming/hoping that you're using OAuth2 instead. If not, I would suggest you to migrate soon as possible.

When working with access tokens, it is important to remember that they have limited lifetimes. Hence, always remember to add them "programmatically". Depending on the API you're trying to access, access tokens are appended to the request as the value of the access_token query parameter of your request. Here are a couple of examples:

GET https://www.googleapis.com/plus/v1/people/userId?access_token=1/fFBGRNJru1FQd44AzqT3Zg

https://www.googleapis.com/youtube/v3/channels?part=id&mine=true&access_token=ACCESS_TOKEN

So look up the Google Developers documentation for the particular API you're using for help on what the exact request will be like. Here are a few samples for using OAuth2 with Google App Script. Hope this helps.

EDIT: A little correction. For OAuth1, the access token is passed using oauth_token. For clarity of how the process flows, refer to the subheadings 6.1 to 6.3.2 in this link and the former one for how it is done on Google's end.

Also, quoting this link:

"April 20, 2015: OAuth 1.0 is shut down. A static error page will be displayed on all requests. Make sure you have migrated well before this date."

If that hasn't already happened, it might happen anytime as currently OAuth1 is "officially" shut down.

pointNclick
  • 1,584
  • 1
  • 12
  • 17