Tests the key by querying the Datawrapper-API for user information.

dw_test_key(api_key = "environment")

Arguments

api_key

Required. A Datawrapper-API-key as character string. Defaults to "environment" - tries to automatically retrieve the key that's stored in the .Reviron-file by datawrapper_auth.

Value

A S3-structure of type dw_user with the elements from the Datawrapper-API, and the following fields:

status

Returns 'ok' if the API-key used was correct.

data$user$id

Returns the internal user id.

data$user$email

The users e-mail adress.

data$user$isAdmin

Specifies, if the current user is admin in his/her organization.

data$user$organization$id

Returns the organization's id or short name.

data$user$organization$name

Returns the organization's full name.

Note

This function tests the API key by retrieving information about the current user from the API. If this works, the API-key is set correctly and ready to go.

Examples

if (FALSE) dw_test_key() # uses the preset key in the .Renviron-file if (FALSE) dw_test_key(api_key = "1234ABCD") # uses the specified key