authorization: Standalone OAuth authorization functions

Description Usage Arguments Details Value Examples

Description

Standalone OAuth authorization functions

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
build_authorization_uri(
  resource,
  tenant,
  app,
  username = NULL,
  ...,
  aad_host = "https://login.microsoftonline.com/",
  version = 1
)

get_device_creds(
  resource,
  tenant,
  app,
  aad_host = "https://login.microsoftonline.com/",
  version = 1
)

Arguments

resource, tenant, app, aad_host, version

See the corresponding arguments for get_azure_token.

username

For build_authorization_uri, an optional login hint to be sent to the authorization endpoint.

...

Named arguments that will be added to the authorization URI as query parameters.

Details

These functions are mainly for use in embedded scenarios, such as within a Shiny web app. In this case, the interactive authentication flows (authorization code and device code) need to be split up so that the authorization step is handled separately from the token acquisition step. You should not need to use these functions inside a regular R session, or when executing an R batch script.

Value

For build_authorization_uri, the authorization URI as a string. This can be set as a redirect from within a Shiny app's UI component.

For get_device_creds, a list containing the following components:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
build_authorization_uri("https://myresource", "mytenant", "app_id",
                        redirect_uri="http://localhost:8100")

## Not run: 

## obtaining an authorization code separately to acquiring the token
# first, get the authorization URI
auth_uri <- build_authorization_uri("https://management.azure.com/", "mytenant", "app_id")
# browsing to the URI will log you in and redirect to another URI containing the auth code
browseURL(auth_uri)
# use the code to acquire the token
get_azure_token("https://management.azure.com/", "mytenant", "app_id",
    auth_code="code-from-redirect")


## obtaining device credentials separately to acquiring the token
# first, contact the authorization endpoint to get the user and device codes
creds <- get_device_creds("https://management.azure.com/", "mytenant", "app_id")
# print the login instructions
creds$message
# use the creds to acquire the token
get_azure_token("https://management.azure.com/", "mytenant", "app_id",
    auth_type="device_code", device_creds=creds)


## End(Not run)

AzureAuth documentation built on Sept. 13, 2021, 5:06 p.m.