namc_oauth2: namc_oauth2

namc_oauth2R Documentation

namc_oauth2

Description

R6 class for handling NAMC oAuth2

Value

a namc_oauth2 class (R6 class)

Super class

NAMCr::base_class -> namc_oauth2

Public fields

is_configured

shows the configured state of the namc_oauth2 object Set connection details

Sets the clientID and URL for the authentication provider

Methods

Public methods

Inherited methods

Method set_connection_details()

Usage
namc_oauth2$set_connection_details(clientId, domain)
Arguments
clientId

string The auth clientID.

domain

string The auth domain name.

Returns

namc_oauth2 An R6 class.

Examples
auth_config = list(...) # namc_oauth2 public or private variables
auth = namc_oauth2$new(argList = auth_config)
auth$set_connection_details("XXXXXXXXXX", "namc.XXXXXXX.edu")

Get user info

Gets the user information from the auth provider once authenticated.


Method get_user_info()

Usage
namc_oauth2$get_user_info()
Returns

list A list containing the available user data.

Examples
auth_config = list(...) # namc_oauth2 public or private variables
auth = namc_oauth2$new(argList = auth_config)
user_info = auth$get_user_info()

Get oAuth2 token

Gets and oAuth2 token object which can be used for subsequent connections.
A stop error occurs if this authentication object has not been configured via
set_connection_details().


Method get_token()

Usage
namc_oauth2$get_token(auto_refresh = TRUE)
Arguments
auto_refresh

Logical TRUE/FALSE to override the objects default behavior

Returns

list An oAuth2 token structure from httr::oauth2.0_token

Examples
auth_config = list(...) # namc_oauth2 public or private variables
auth = namc_oauth2$new(argList = auth_config)
oauth_token = auth$get_token()

Get access token

Extracts the access token from the cached oAuth2 credential. This is
used for the Bearer Authentication header.


Method get_access_token()

Usage
namc_oauth2$get_access_token()
Returns

string The oAuth2 access token

Examples
auth_config = list(...) # namc_oauth2 public or private variables
auth = namc_oauth2$new(argList = auth_config)
oauth_access_token = auth$get_access_token()

Check refresh token

Check if the oAuth2 token needs refreshing


Method requires_refresh()

Usage
namc_oauth2$requires_refresh()
Returns

namc_oauth2 An R6 class.

Examples
auth_config = list(...) # namc_oauth2 public or private variables
auth = namc_oauth2$new(argList = auth_config)
auth$requires_refresh()

Refresh token

Refreshes the oAuth2 token


Method refresh_token()

Usage
namc_oauth2$refresh_token()
Returns

namc_oauth2 An R6 class.

Examples
auth_config = list(...) # namc_oauth2 public or private variables
auth = namc_oauth2$new(argList = auth_config)
auth$refresh_token()

Reset token

Deletes cached token file .httr-oauth


Method reset_token()

Usage
namc_oauth2$reset_token()
Returns

namc_oauth2 An R6 class.

Examples
auth_config = list(...) # namc_oauth2 public or private variables
auth = namc_oauth2$new(argList = auth_config)
auth$reset_token()


Method clone()

The objects of this class are cloneable with this method.

Usage
namc_oauth2$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples


auth_config = list(...) # namc_oauth2 public or private variables
auth = namc_oauth2$new(argList = auth_config)


## ------------------------------------------------
## Method `namc_oauth2$set_connection_details`
## ------------------------------------------------


auth_config = list(...) # namc_oauth2 public or private variables
auth = namc_oauth2$new(argList = auth_config)
auth$set_connection_details("XXXXXXXXXX", "namc.XXXXXXX.edu")

Get user info

Gets the user information from the auth provider once authenticated.


## ------------------------------------------------
## Method `namc_oauth2$get_user_info`
## ------------------------------------------------


auth_config = list(...) # namc_oauth2 public or private variables
auth = namc_oauth2$new(argList = auth_config)
user_info = auth$get_user_info()

Get oAuth2 token

Gets and oAuth2 token object which can be used for subsequent connections.
A stop error occurs if this authentication object has not been configured via
set_connection_details().


## ------------------------------------------------
## Method `namc_oauth2$get_token`
## ------------------------------------------------


auth_config = list(...) # namc_oauth2 public or private variables
auth = namc_oauth2$new(argList = auth_config)
oauth_token = auth$get_token()

Get access token

Extracts the access token from the cached oAuth2 credential. This is
used for the Bearer Authentication header.


## ------------------------------------------------
## Method `namc_oauth2$get_access_token`
## ------------------------------------------------


auth_config = list(...) # namc_oauth2 public or private variables
auth = namc_oauth2$new(argList = auth_config)
oauth_access_token = auth$get_access_token()

Check refresh token

Check if the oAuth2 token needs refreshing


## ------------------------------------------------
## Method `namc_oauth2$requires_refresh`
## ------------------------------------------------


auth_config = list(...) # namc_oauth2 public or private variables
auth = namc_oauth2$new(argList = auth_config)
auth$requires_refresh()

Refresh token

Refreshes the oAuth2 token


## ------------------------------------------------
## Method `namc_oauth2$refresh_token`
## ------------------------------------------------


auth_config = list(...) # namc_oauth2 public or private variables
auth = namc_oauth2$new(argList = auth_config)
auth$refresh_token()

Reset token

Deletes cached token file .httr-oauth


## ------------------------------------------------
## Method `namc_oauth2$reset_token`
## ------------------------------------------------


auth_config = list(...) # namc_oauth2 public or private variables
auth = namc_oauth2$new(argList = auth_config)
auth$reset_token()


namc-utah/NAMCr documentation built on Feb. 12, 2024, 4:29 a.m.