Description Usage Arguments Details Value See Also Examples
Functions related to creating or retrieving an OAuth 2.0 token for the Hubspot API.
1 2 3 4 5 6 7 8 9 | default_ld_hubspot_app()
hubspot_token_create(
app_info = default_ld_hubspot_app(),
set_renv = TRUE,
token_path = NULL
)
hubspot_token_get()
|
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 |
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,
Read and execute Hubspot’s docs about how to create an app. You’ll need to create a Hubspot developer account.
Define the app_info
list.
my_very_own_app <- list(client_secret = <CLIENTSECRET>, client_id = <CLIENTID>, app_id = <APPID>, scope = c(<"scope1", "scope2", etc>))
Pass the app info to hubspot_token_create()
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.
If the token expires in less than 60 seconds, it’ll be refreshed and cached thanks to the refresh token.
The Hubspot API accepts authorization via
an API key,
OAuth 2.0.
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:
For rapid prototyping key, use a Hubspot API key, see
hubspot_key_set()
.
For more secure use, without a daily limit on API calls, see
hubspot_token_create()
to create a Hubspot authorization token
(OAuth 2.0).
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.
Named list
Either NULL or the path in which the token is saved.
Other auth:
hubspot_key_get()
1 2 3 4 5 6 | default_ld_hubspot_app()
## Not run:
hubspot_token_create()
## End(Not run)
hubspot_token_get()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.