Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAuth1a without TokenUrl #36

Closed
jasongurwin opened this issue Dec 1, 2017 · 5 comments
Closed

OAuth1a without TokenUrl #36

jasongurwin opened this issue Dec 1, 2017 · 5 comments

Comments

@jasongurwin
Copy link

I'm trying to use an API that requires OAuth1 but doesn't use an URL. It just wants the consumerKey, consumerSecret, accessToken (same as consumerKey), and accessSecret (same as consumerSecret).

Are there any examples on how to use this library with it?

@erickoledadevrel
Copy link

Take a look at the Yelp sample:

https://github.com/googlesamples/apps-script-oauth1/blob/master/samples/Yelp.gs

I think you too can use the setAccessToken method to just set the access token manually using the consumer key and secret.

@jasongurwin
Copy link
Author

I am using that example, but I get the following error. Is there a way to get the raw request URL being made and response?

Request failed for https://api.semantics3.com/v1/products returned code 401. Truncated server response: {"code":"OAuthError","message":"OAuth Authentication Failed"} (use muteHttpExceptions option to examine full response) (line 443, file "Service", project "OAuth1")

@erickoledadevrel
Copy link

I've been trying to get that API to work with the library over the past few days and I can't figure out what the problem is. I get the same error, but I have no idea what the problem is.

If you call .setParamLocation('uri-query') when building the Service object then you'll be able to see the full URL being constructed when the error fails. Everything looks normal, so I'm not sure where the problem lies.

@erickoledadevrel
Copy link

Thanks to @amarnus for figuring out the issue. The API uses 1-legged OAuth, where you set the access_token and secret to the empty string, not the consumer key and secret. I've published a working sample here:

https://github.com/googlesamples/apps-script-oauth1/blob/master/samples/Semantics3.gs

@jasongurwin
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants