Authenticating into WildTrax
authenticating-into-wt.Rmd
Set up credentials
To obtain an Auth0 token, you must login into WildTrax using Auth0 (Google authorization is currently not supported). You also need to store your WildTrax user name and password as environment variables.
# Note that you need to use 'WT_USERNAME' and 'WT_PASSWORD'.
Sys.setenv(WT_USERNAME = 'guest', WT_PASSWORD = 'Apple123')
Authenticate
Next, you use the wt_auth()
function to
authenticate.
# Authenticate
wt_auth()
The Auth0 token you obtained will last for 12 hours. After that time, you will need to re-authenticate.
Making API calls
Once authenticated, you can now use various functions that call upon
the WildTrax API. For instance, you can use
wt_get_download_summary()
to see basic metadata about
projects that you can download data for.
#Download the project summary you have access to
<- wt_get_download_summary(sensor_id = 'ARU')
my_projects
my projects
Using the project_id number in the download summary you can then use
wt_download_report
to access the species data. You can also
find the project_id number in the url of a WildTrax project, e.g. https://www.wildtrax.ca/home/aru-tasks.html?projectId=47&sensorId=ARU
#Download the project report
my_report <- wt_download_report(project_id = 41, sensor_id = 'ARU', cols_def = F, weather_cols = T)
my_report