Skip to content

Improve OAuth docs #330

Closed
Closed
@llrs

Description

@llrs

This issue explores how to manage refresh tokens with httr2 (linked to #316 questions) created with oauth_flow_auth_code.

When a website provides a token with a changing refresh token I haven't found a method without requesting confirmation from the user:

  • oauth_flow_auth_code: Create a new token, so it needs to be validated again in the browser by the user when updating it.
  • oauth_flow_refresh: Should not be used
  • req_oauth_auth_code could cache the token but it would revert to oauth_flow_auth_code when enough time passes.
  • I haven't find other functions are meant for this kind of authentication.

I was using oauth_flow_refresh because it was the only way to self-manage the tokens without asking for confirmation from the user. It is unclear to me if req_oauth_auth_code would overwrite the token store the token too shortly.

In short, I wish to be able to refresh a token and self-manage it.


In addition, I think I was confused by the name of the function req_auth_bearer_token, which should be used for all tokens. Maybe req_auth could be a better name if a single function could handle all the token types (without needing to to something like token$access_token like in the vignettes).

As a summary I made while looking into this, in case someone else finds it helpful:

Obtain token Update token Authenticate token
oauth_flow_client_credentials() req_oauth_client_credentials() req_auth_bearer_token()
oauth_flow_device() req_oauth_device() req_auth_bearer_token()
oauth_flow_bearer_jwt req_oauth_bearer_jwt() req_auth_bearer_token()
oauth_flow_password() req_oauth_password() req_auth_bearer_token()
oauth_flow_refresh()* req_oauth_refresh() req_auth_bearer_token()
oauth_flow_auth_code() req_oauth_auth_code() req_auth_bearer_token()
oauth_flow_device() req_oauth_device

*: Shouldn't be used except for testing interactively.

Usually the req_auth_* function is only mentioned on the auth_flow_* function help pages. But not the other way around: the req_auth_* do not mention auth_flow_*.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions