-
Notifications
You must be signed in to change notification settings - Fork 2k
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
One legged OAuth1 #542
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Ok I was wrong and jump to conclusion too quickly. here is how to do it but it is advanced use because completely undocumented example I think. For the Oauth1 API of NOUNS you need to get the signature using you key and secret. There is no exchange of token so no oauth dance. The function to get the signature is nouns_app <- httr::oauth_app("nouns_api", Sys.getenv("NOUNS_API_KEY"), Sys.getenv("NOUNS_API_SECRET"))
get_nouns_api <- function(endpoint, baseurl = "http://api.thenounproject.com/", app = nouns_app) {
url <- httr::modify_url(baseurl, path = endpoint)
info <- httr::oauth_signature(url, app = app)
header_oauth <- httr::oauth_header(info)
httr::GET(url, header_oauth)
}
res <- get_nouns_api("icon/15")
httr::status_code(res)
#> [1] 200
str(httr::content(res), 1)
#> List of 1
#> $ icon:List of 23
res <- get_nouns_api("collections")
httr::status_code(res)
#> [1] 200
str(httr::content(res), 1)
#> List of 1
#> $ collections:List of 50 Created on 2018-10-18 by the reprex package (v0.2.1) With this, you'll be able to complete you nounsapi 📦 . I am willing to help by doing a PR there if you want. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…on Github in response to this issue: r-lib/httr#542. Dividing functions into three groups for different stages. Writing tests.
…on Github in response to this issue: r-lib/httr#542. (#6) Dividing functions into three groups for different stages. Writing tests.
httr is coming back to life, so if you're still interested in this I'd love to hear suggestions as the best way forward. |
Having fully read this issue, it seems like maybe this is a documentation problem? Also is this the same issue as #323? |
All the functions where already in httr - Lines 18 to 21 in 976289a
It implements two steps from what I came up with for Nouns API. I don't know if it should be exported. So Yes I think also this is something that needs to be more documented as it works assuming you know how to do it. Do you think a vignette is better than a new demo file in Also, I think the issue is different in #323 as it involves a token - so |
Adding a little more documentation, and an example, would help, I think. |
I think another demo is probably adequate. I don't want to invest too much time in this because we're planning to work on httr2 later next year, and it'll have a completely revamped OAuth system. |
using Noun Project API (r-lib#542)
Sorry but I can't seem to make httr work with the Noun Project API).
The site suggests a very simple access based just on the key and the secret.
My R code is as follows:
It opens a browser window but gives a
"Bad Request
Missing OAuth parameters"
response.
This seems like it should be a really simple problem - like a gap between how httr and the API are handling the key and secret - perhaps API is not recognising the text of the key for some reason.
I imagine I'm doing something really stupid but I'm really at my wits end trying to make this work and would love a bit of help if anybody recognises the problem.
Thanks,
Paul
The text was updated successfully, but these errors were encountered: