제목에서 알 수 있듯이 reddit API에 연결하려고합니다. 프로필에 comment extractor라는 앱을 만들었고 copy 공개 키와 비밀 키를 붙여 넣은 다음 http://localhost:1410/을 리디렉션 URI 및 URL로 사용하십시오. 응용 프로그램은 스크립트지만, 나는 같은 결과와 함께 웹 애플 리케이션을 시도.htth 패키지의 oauth_token2.0을 사용하여 reddit API에서 항상 401 오류가 발생합니다.
은 내가 사용하고 코드는 단지 Hadleys HTTR을 데모에서 붙여 넣기,하지만 난 내 자신의 (HTTR의 최신 버전, 1.3.1 함께 할 모든 것을)의 키를 교환 복사됩니다.
는library(httr)
# 1. Find OAuth settings for 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 an application at https://www.reddit.com/prefs/apps
app <- oauth_app("comment extractor", "rrG5wfgHkm5Kvw", "[secret key]")
# 3b. If get 429 too many requests, the default user_agent is overloaded.
# If you have an application on Reddit then you can pass that using:
token <- oauth2.0_token(
reddit, app,
scope = c("read", "modposts"),
use_basic_auth = TRUE,
config_init = user_agent("reddit_username")
)
웹 브라우저는 내가 허용하거나 토큰을 거부하도록 요청하고있어, 열고, 다 잘 보이지만, 항상이 메시지
Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
Authentication complete.
Error in oauth2.0_access_token(endpoint, app, code = code, user_params =
user_params, :
Unauthorized (HTTP 401). Failed to get an access token.
내가 함께 무엇을 해야할지 확신했다 실패 사용자 에이전트, 나는 개발자의 이름을 묻는 것으로 나타났습니다. 그래서 임의의 텍스트를 두 개 시도하고, reddit 사용자 이름을 사용했는데, 항상 잘못된 키를 의미하는 401 오류가 나타납니다.
어떤 도움을 크게 감상 할 수, 내가 가장 기본적인 단계에서 중지 얻고 다음에 무엇을 모를 때 손실에 다소 해요.
여기에 업데이트됩니다 내가 알아낼 수 있다면, 나는 꽤 많이 생각해 낸 것을 다 써 버렸다. 나는 해들리 나 다른 누군가가해야 할 일에 대한 아이디어를 가지고 있기를 바란다. httr 패키지 github에서 문제를 열었다. 잘못하고있는 것). –