r - Always get 401 error from reddit API using oauth_token2.0 from httr package -
as title says, i'm trying connect reddit api, i've created app (named comment extractor) on profile, , copy paste public , secret keys, , use http://localhost:1410/ redirect uri , url. app script, tried web app same result.
the code i'm using copy pasted hadleys httr demos, exchanged keys own (everything done latest version of httr, 1.3.1).
library(httr) # 1. find oauth settings reddit: # https://github.com/reddit/reddit/wiki/oauth2 reddit <- oauth_endpoint( authorize = "https://www.reddit.com/api/v1/authorize", access = "https://www.reddit.com/api/v1/access_token" ) # 2. register application @ https://www.reddit.com/prefs/apps app <- oauth_app("comment extractor", "rrg5wfghkm5kvw", "[secret key]") # 3b. if 429 many requests, default user_agent overloaded. # if have application on reddit can pass using: token <- oauth2.0_token( reddit, app, scope = c("read", "modposts"), use_basic_auth = true, config_init = user_agent("reddit_username") )
the web browser opens, i'm asked allow or deny token, , seems fine, fails message
waiting authentication in browser... press esc/ctrl + c abort authentication complete. error in oauth2.0_access_token(endpoint, app, code = code, user_params = user_params, : unauthorized (http 401). failed access token.
i unsure of user agent, noticed app asks developer names tried both random text , using reddit username there, either way, 401 error, seems mean wrong keys, definately aren't.
any appreciated, i'm @ loss when stopped @ basic step , don't know next.
Comments
Post a Comment