tm_token: Get TrendMiner access token

Description Usage Arguments Details Value Examples

View source: R/authentication.R

Description

Requests a Bearer access token from TrendMiner using an OAuth2.0 resource owner password credentials grant flow.

Usage

1
2
3
4
5
6
7
8
tm_token(
  client_id = NULL,
  client_secret = NULL,
  usr_name = NULL,
  usr_pwd = NULL,
  base_url = NULL,
  ...
)

Arguments

client_id

Client identifier issued by the authorization server

client_secret

Client secret issued by the authorization server

usr_name

Username

usr_pwd

User password

base_url

TrendMiner base URL

...

Additional arguments passed on to the underlying HTTP method. This might be necessary if you need to set some curl options explicitly via config.

Details

All requests to the TrendMiner API require authentication. This is achieved by sending a valid Bearer access token in the request headers. Request tokens are obtained via OAuth2.0 using the resource owner password credentials flow: Any client which likes to interact with the API needs to collect the credentials from the user (username and password) and passes them together with its own client credentials (client ID and client secret) to the TrendMiner server. The server responds with an access token which the user needs to use for any subsequent API requests.

Note: You can request your client ID and client secret by contacting TrendMiner support or your TrendMiner Customer Success Manager.

User credentials, client credentials and the TrendMiner base URL can be passed as arguments to tm_token() for quick testing in interactive mode. However, it is recommended to call tm_token() without arguments. In this case tm_token() will fetch the credentials and the TrendMiner base URL from the following environment variables stored in .Renviron which you can easily edit using usethis::edit_r_environ():

TM_client_ID = YOUR_CLIENT_ID_HERE
TM_secret = YOUR_CLIENT_SECRET_HERE
TM_usr = YOUR_USER_NAME_HERE
TM_pwd = YOUR_USER_PASSWORD_HERE
TM_base_url = YOUR_TM_BASE_URL_HERE

Value

A S3 object of class tm_token (basically a list) with the following components:

Examples

1
2
3
4
## Not run: 
tm_token()

## End(Not run)

TrendMiner/trendminer documentation built on Jan. 30, 2020, 12:21 a.m.