---
title: "Authentication"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Authentication}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

Set up a valid authentication to the 'HERE' REST APIs and optionally configure a proxy.

## Application credentials
In order to use the functionality of the `hereR` package, application credentials for a HERE project must be provided. The HERE application credentials (API Key) can be obtained for free as follows:

1. Go to [developer.here.com](https://developer.here.com/)
2. Sign up for a HERE developer account, which automatically creates a new project 
3. Click 'REST: Generate APP'
4. Click 'Create API Key' and copy the key

The API key is set for the current R session and will be used to authenticate in the requests to the HERE REST APIs (250K free transactions per month).
To set the key, please use:

```{r set}
library(hereR)
set_key("<YOUR API KEY>")
```


## Information about requests

By default, the `hereR` package does not print messages with information about the
requests sent and the data received from to the HERE APIs. If this information should be printed for the current R session, use:

```{r set_verbose}
set_verbose(TRUE)
```

Use `set_Verbose(FALSE)` to set the `hereR` package to be quiet again.

## Proxy
If you are working behind a proxy and you don't want to change the global proxy settings of RStudio, the proxy information can be passed directly to the `hereR` package.
If a proxy is needed, it can be set as follows: 

```{r proxy}
set_proxy(
  proxy = "https://<YOUR-PROXY.NET>:<PORT>/",
  proxyuserpwd = "<USER>:<PASSWORD>"
)
```

**Note:** Only functions of the `hereR` package are now using the proxy. Other functions sending requests to the web continue to encounter timeout errors.

## Remove credentials
To remove previously set credentials from the current R session use `unset_key()`. In order to delete the proxy information use `unset_proxy()`. For overwriting application credentials or proxy settings use again the `set_key()` and `set_proxy()` functions.

## Reference

* [Sign up as developer](https://developer.here.com/sign-up?create=Freemium-Basic&keepState=true&step=account)
* [Pricing and plans](https://developer.here.com/pricing)

