In order to use Open Transport you must provide an API key in each request.
Failing to provide an API key or providing an incorrect or expired key will result in a 401 Unauthorized
error.
You can obtain a key from the Open Transport Console.
The recommended way to provide the API key is to set the Authorization
header for each request.
Authorization: Bearer API_KEY_GOES_HERE
API_KEY_GOES_HERE
- (string) Your API keyAn alternative approach to supplying the key is to use the key
URL query parameter:
GET /api/beta/vehicles/example?key=API_KEY_GOES_HERE
API_KEY_GOES_HERE
- (string) Your API keySetting headers in HTTP requests is common practice, this section decribes how to achieve it in various languages.
You can use jQuery’s beforeSend
callback to add an HTTP header with the authentication information:
beforeSend: function (xhr) {
xhr.setRequestHeader ("Authorization", "Bearer " + apiKey);
}
Use the Header
map on an http.Request
to set the Authorization
header in Go:
req, err := http.NewRequest("GET", "/path", nil)
if err != nil {
return err
}
req.Header.Set("Authorization", "Bearer " + apiKey)