hubspot-oauth: Create/retrieve Hubspot authorization token.

Description Usage Arguments Details Value See Also Examples

Description

Functions related to creating or retrieving an OAuth 2.0 token for the Hubspot API.

Usage

1
2
3
4
5
6
7
8
9

Arguments

app_info

A named list with client_secret, client_id, app_id, required scope, optional scope (NULL if no additional scope).

set_renv

Logical indicating whether to save the created token as the default environment hubspot token variable. Defaults to TRUE, meaning the token is saved to user's home directory as either the user provided path, or ".hubspot_token.rds" (or, if that already exists, then .hubspot_token1.rds or .hubspot_token2.rds, etc.) and the path to the token to said token is then set in the user's .Renviron file and re- read to start being used in current active session.

token_path

Path where to save the token. If set_renv is FALSE, this is ignored.

Details

We expect you to not need to bring your own app (BYOA), but the app_info parameter of hubspot_token_create() ensures you can do that if you want (for instance to define an app with only the scope needed for the endpoints you use as opposed to all the endpoints the hubspot package supports; or to be sure your requests do not end up in the logs of our default app but instead in an app your organization controls).

To BYOA,

end list
my_very_own_app <- list(client_secret = <CLIENTSECRET>,
       client_id = <CLIENTID>,
       app_id = <APPID>,
       scope = c(<"scope1", "scope2", etc>))
end list
hubspot_token_create(app_info = my_very_own_app)

To distribute your app across your projects or across team members, you could make it a function in an internal package, or use environment variables.

Token refreshing

If the token expires in less than 60 seconds, it’ll be refreshed and cached thanks to the refresh token.

Authorization for Hubspot APIs

The Hubspot API accepts authorization via

OAuth 2.0 is the recommended method. However, this package supports both.

Note that if you do nothing the package will use the “demo” API token but this won’t give you access to your own Hubspot data. So you’ll need to spend a little time on setup:

If you have both saved an API key via hubspot_key_set() and a token via hubspot_token_create(), priority will be given to using the OAuth 2.0 token. If you don’t want that, explicitely pass NULL as value for the token_path argument of all functions.

Value

Named list

Either NULL or the path in which the token is saved.

See Also

Other auth: hubspot_key_get()

Examples

1
2
3
4
5
6

lockedata/hubspot documentation built on March 1, 2020, 8:54 p.m.