-
Notifications
You must be signed in to change notification settings - Fork 12
Use one rfigshare app #72
Comments
Except that keys are tied to individual accounts. We can't all upload data into a single account. Each researcher needs their own to maintain research collections, track metrics etc. |
Each user needs their own account, but not their own app. i.e. |
Ah, right. Good point. I forgot that Figshare does this (most other data providers don't distinguish from application specific keys to user keys). I like this plan and I think we can implement it. It would be great too, because we can ask the figshare folks for data on usage based on the app key. |
@hadley Yes, this makes sense, and would streamline users getting up and running. We would then just use a call to Unfortunately, my first stab at this didn't work. After authenticating successfully in the browser, R just gives me the error I described earlier: Not sure where I've gone wrong. |
@cboettig Which error? The 405? Or the cache related? |
@hadley the 405 error. Sorry I should have copy-pasted. request <- "request_token"
authorize <- "authorize"
access <- "access_token"
base_url <- "http://api.figshare.com/v1/pbl/oauth"
endpoint <- oauth_endpoint(request, authorize, access, base_url=base_url)
# endpoint <- oauth_endpoint(NULL, authorize, access, base_url=base_url) # tried this too since docs say oauth 1 doesn't need a request token? a bit confused, no dice.
myapp <- oauth_app("rfigshare", key = cKey, secret=cSecret)
token <- oauth1.0_token(endpoint, myapp) This takes me to the figshare website where I sign in and click "allow" as expected, then R gives me the error:
|
You're sure you're running the latest httr? |
@hadley apparently I'm not, whoops! Works like a charm. If only I was better at managing my versions... Time to update rfigshare.... |
@hadley A few quick questions
token <- oauth1.0_token(endpoint, myapp)
assign('token', token, envir=FigshareAuthCache) but that seems like I'm just sidestepping the httr mechanism. Alternately, it looks like you've defined methods for > cache(token)
Error: could not find function "cache" and get that error. How should I be caching? (I did check
|
|
oauth <- oauth1.0_token(endpoint, myapp)
GET("http://api.figshare.com/v1/my_data/articles") gives me the error Response [http://api.figshare.com/v1/my_data/articles]
Status: 401
Content-type: application/json; charset=UTF-8
{"error": "No Authorization header present!. Make sure you add oauth parameters in header"} How was I supposed to tell GET to load the token from the cache? |
You still need to do But you should still save the token in an environment - httr's caching is mostly aimed at caching across sessions. In other words, people won't need to record their api key and secret key any more, because httr will do that for them. Combined with including the app key & secret that should mean that you don't need to do any setup to use rfigshare. |
Ah, very good, that all makes perfect sense. was slowly coming to this On Tue, Mar 18, 2014 at 1:52 PM, Hadley Wickham notifications@github.comwrote:
Carl Boettiger |
Unclear how token caching works at this time. Currently code still uses the environment variable to cache, and makes a repeated call to fs_auth if the token is not available. Perhaps repeating the call is how we are supposed to load stored tokens?
@hadley One more strange thing here: everything works fine if I load httr explicitly, but I get an error otherwise (though httr is in IMPORTS). Working from the current devel branch: > require(rfigshare)
Loading required package: rfigshare
fs)> fs_auth()
Error: cache should be length 1 vector
Enter a frame number, or 0 to exit
1: fs_auth()
2: oauth1.0_token(endpoint, myapp)
3: new_token(Token1.0, endpoint, app, params, cache = cache)
4: use_cache(cache) errors, while: > library(httr)
> fs_auth()
Use a local file to cache OAuth access credentials between R sessions?
1: Yes
2: No
Selection: 1
Adding .httr-oauth to .gitignore
Loading required package: httpuv
Loading required package: Rcpp
Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
Authentication complete.
Authentication successful
> works fine. |
Can you please try again now? I just pushed a probable fix. |
Yup, that worked! thanks! |
hi guys, will it still possible to use keys hardwired in a R code? Thanks for all your work, rfigshare is great! On 18 mars 2014, at 22:21, Carl Boettiger notifications@github.com wrote:
|
@jcolomb rfigshare will still upload to whatever user account you want using the same commands it always has used. The first time you'll be asked to login to figshare, just like you have to do the first time you currently use rfigshare in order to look up your tokens. The only difference is that now instead of having to look up your tokens manually and paste them in manually, it just happens automatically with the click of a button. That will be the only change. Everything else is the same. As far as whether you share the login credentials or the token credentials of some shared figshare account, that's all up to you. Giving a bunch of users a copy of the tokens for an account isn't functionally different then giving them the account name and password, and I suspect the latter is more intuitive for everyone. |
@jcolomb Would you mind test-driving library(devtools)
install_github("rfigshare", "ropensci") Let me know if you have any issues. |
Each user shouldn't need there own - it's safe to distribute app key and secret in the package.
The text was updated successfully, but these errors were encountered: