Retrieve a fresh waterinfo token. A token is not required to get started, see Details section for more information.

get_token(client = NULL, client_id = NULL, client_secret = NULL,
  token_url = "http://download.waterinfo.be/kiwis-auth/token")

is.expired(token)

expires.in(token)

Arguments

client

base64 encoded client containing the client id and client secret, seperated by :

client_id

client id string

client_secret

client secret string

token_url

url to get the token from

token

a token object

Value

An object of class token containing the token string with the token_url, token type and moment of expiration as attributes.

Details

Notice you do not need to get a token right away to download data. For limited and irregular downloads, a token will not be required. The amount of data downloaded from waterinfo.be is limited via a credit system. When you require more extended data requests, request a download token.

Either client or client_id and client_secret need to be passed as arguments. If provided, client is always used. Tokens remain valid for 24 hours, after which a fresh one must be acquired. To limit load on the server, token objects should be reused as much as possible until expiration in stead of creating fresh ones for each call.

The client_id and client_secret provided in the examples are for test purposes, get your very own client via hydrometrie@waterinfo.be.

Examples

# Get token via client_id and client_secret client_id <- '32dceece-826c-4b98-9c2d-b16978f0ca6a' client_secret <- '4ada871a-9528-4b4d-bfd5-b570ce8f4d2d' my_token <- get_token(client_id = client_id,client_secret = client_secret) print(my_token)
#> Token: #> eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIyZmFjYjc0MS1hNzk4LTRhOTYtOGJmYy03MmVjZDYxOTU2ZTMiLCJpYXQiOjE1NjQ1NzI3ODYsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6ODA4MC9LaVdlYlBvcnRhbC9hdXRoIiwiYXVkIjoiMzJkY2VlY2UtODI2Yy00Yjk4LTljMmQtYjE2OTc4ZjBjYTZhIiwiZXhwIjoxNTY0NjU5MTg2fQ.azGKzjBW6HcpL1EDL697Mvw1ElKWUA71hJMWSRn9q1s #> #> Attributes: #> url: http://download.waterinfo.be/kiwis-auth/token #> type: Bearer #> expires: 2019-08-01 11:33:06 UTC
# get token via client client <- paste0('MzJkY2VlY2UtODI2Yy00Yjk4LTljMmQtYjE2OTc4ZjBjYTZhOjRhZGE4', 'NzFhLTk1MjgtNGI0ZC1iZmQ1LWI1NzBjZThmNGQyZA==') my_token <- get_token(client = client) print(my_token)
#> Token: #> eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI4ZjhlMjYxNy0xY2VhLTQ5N2YtOTYzYS1lZGMzMmFiZWE0OWQiLCJpYXQiOjE1NjQ1NzI3ODYsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6ODA4MC9LaVdlYlBvcnRhbC9hdXRoIiwiYXVkIjoiMzJkY2VlY2UtODI2Yy00Yjk4LTljMmQtYjE2OTc4ZjBjYTZhIiwiZXhwIjoxNTY0NjU5MTg2fQ.t4dHwr6aGakY2hpxL_mD6YKlxaWOy-OVZZIFECbSNOo #> #> Attributes: #> url: http://download.waterinfo.be/kiwis-auth/token #> type: Bearer #> expires: 2019-08-01 11:33:06 UTC
is.expired(my_token)
#> [1] FALSE
expires.in(my_token)
#> Time difference of 24 hours