oauth2_resource_app {webfakes}R Documentation

Fake OAuth 2.0 resource and authorization app

Description

The webfakes package comes with two fake apps that allow to imitate the OAuth2.0 flow in your test cases. (See Aaron Parecki’s tutorial for a good introduction to OAuth2.0.) One app (oauth2_resource_app()) is the API server that serves both as the resource and provides authorization. oauth2_third_party_app() plays the role of the third-party app. They are useful when testing or demonstrating code handling OAuth2.0 authorization, token caching, etc. in a package. The apps can be used in your tests directly, or you could adapt one or both of them to better mimic a particular OAuth2.0 flow.

Usage

oauth2_resource_app(
  access_duration = 3600L,
  refresh_duration = 7200L,
  refresh = TRUE,
  seed = NULL,
  authorize_endpoint = "/authorize",
  token_endpoint = "/token"
)

Arguments

access_duration

After how many seconds should access tokens expire.

refresh_duration

After how many seconds should refresh tokens expire (ignored if refresh is FALSE).

refresh

Should a refresh token be returned (logical).

seed

Random seed used when creating tokens. If NULL, we rely on R to provide a seed. The app uses its own RNG stream, so it does not affect reproducibility of the tests.

authorize_endpoint

The authorization endpoint of the resource server. Change this from the default if the real app that you are faking does not use ⁠/authorize⁠.

token_endpoint

The endpoint to request tokens. Change this if the real app that you are faking does not use ⁠/token⁠.

Details

The app has the following endpoints:

Notes

For more details see vignette("oauth", package = "webfakes").

Value

a webfakes app

webfakes app

oauth2_resource_app()

App representing the API server (resource/authorization)

See Also

Other OAuth2.0 functions: oauth2_httr_login(), oauth2_login(), oauth2_third_party_app()


[Package webfakes version 1.3.1 Index]