httr2库中的auth_code等效于fetch_token

发布于 2025-02-07 04:47:03 字数 981 浏览 3 评论 0原文

我想复制 python 同时接收访问和刷新令牌的示例,例如(python)

token_response = oauth2_session.fetch_token(TOKEN_GRANT_URL, code=AUTHORIZATION_CODE, client_secret=CLIENT_SECRET)

我如何使用httr2库来进行操作?

我之前的步骤要获得授权 (r)

client <- httr2::oauth_client(token_url = token_grant_url,secret = .app_secret,id = .app_key)
url_to_browse <- httr2::oauth_flow_auth_code_url(client=client, auth_url = auth_url,
                                                 scope = paste0(SCOPES_TO_REQUEST, collapse = " "),
                                                 redirect_uri = .client_redirect,state = STATE)

但我不明白我应该使用哪个功能,而不是fetch_token

感谢您的任何帮助您

还可以提供我离开我发行的链接 HTTR2项目

I want to replicate python example of receiving both access and refresh tokens, like here (Python)

token_response = oauth2_session.fetch_token(TOKEN_GRANT_URL, code=AUTHORIZATION_CODE, client_secret=CLIENT_SECRET)

How could I do it using httr2 library?

There are my previous steps to get the AUTHORIZATION_CODE (R)

client <- httr2::oauth_client(token_url = token_grant_url,secret = .app_secret,id = .app_key)
url_to_browse <- httr2::oauth_flow_auth_code_url(client=client, auth_url = auth_url,
                                                 scope = paste0(SCOPES_TO_REQUEST, collapse = " "),
                                                 redirect_uri = .client_redirect,state = STATE)

But I don't understand which function should I use instead of fetch_token

Thanks for any help you can provide

Also I leave the link of my issue from github page of httr2 project

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

献世佛 2025-02-14 04:47:03

您将使用oauth2.0_token函数( https”> https: //httr.r-lib.org/reference/oauth2.0_token.html

token <- oauth2.0_token(
  endpoint,
  app,
  scope = NULL,
  user_params = NULL,
  type = NULL,
  use_oob = getOption("httr_oob_default"),
  oob_value = NULL,
  as_header = TRUE,
  use_basic_auth = FALSE,
  cache = getOption("httr_oauth_cache"),
  config_init = list(),
  client_credentials = FALSE,
  credentials = NULL,
  query_authorize_extra = list()
)

You would use the oauth2.0_token function (https://httr.r-lib.org/reference/oauth2.0_token.html)

token <- oauth2.0_token(
  endpoint,
  app,
  scope = NULL,
  user_params = NULL,
  type = NULL,
  use_oob = getOption("httr_oob_default"),
  oob_value = NULL,
  as_header = TRUE,
  use_basic_auth = FALSE,
  cache = getOption("httr_oauth_cache"),
  config_init = list(),
  client_credentials = FALSE,
  credentials = NULL,
  query_authorize_extra = list()
)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文