You must authenticate most requests to the API. The API supports 2 schemes: OAuth and Basic authentication.
We strongly recommend that you use OAuth. Use Basic authentication if you are the only user of your application. If you use an organization account, see Authentication for organizations.
Ride with GPS is an OAuth provider, and we recommend that you use OAuth if you plan to authenticate users other than yourself. The workflow is secure, and does not require users to share their Ride with GPS password with you.
On your API clients management page, create or update an API client and specify one or more Redirect URIs (redirect_uri) pointing to endpoints you own. Your API client is then set up for OAuth, and its management page shows your OAuth client ID (client_id) and secret (client_secret). Never share them with anyone.
Your application links your user to the authorization web page hosted on the Ride with GPS website:
<a href="https://ridewithgps.com/oauth/authorize
?client_id={client_id}
&redirect_uri={redirect_uri}
&response_type=code">
Sign in with Ride with GPS
</a>
Where:
redirect_uri must match one of the OAuth redirect URIs configured for your API clientclient_id is the OAuth client ID of your API clientRide with GPS asks the user to sign in if needed, then shows your API client's name and asks them to authorize it to read and modify their content. When they click Authorize, Ride with GPS redirects them to your redirect_uri with an access grant:
{redirect_uri}?code={access_grant}
access_grant for an access_tokenUsing the access grant that was sent to your redirect_uri, your application fetches the access_token:
/oauth/token.json{
"grant_type": "authorization_code",
"code": "{access_grant}",
"client_id": "{client_id}",
"client_secret": "{client_secret}",
"redirect_uri": "{redirect_uri}"
}
redirect_uriin request body must match the one used in the first step above.
{
"access_token": "Qnpa6Bif4gF9s6uU5YwjtxbaP3UzQxgfArDP7HXZj_5",
"token_type": "Bearer",
"scope": "user",
"created_at": 946728000,
"user_id": 123
}
user_id is the Ride with GPS assigned id for the user who completed the authorization flow.access_token authenticates your requests, in an Authorization header:// header
Authorization: Bearer {access_token}
Your application can then make requests on the Ride with GPS API with the Authorization header to authenticate as your user. For example to get more details about the user who just completed the OAuth flow:
Authorization: Bearer {access_token}To revoke an OAuth access token, send this request:
/oauth/revoke.json{
"client_id": "{client_id}",
"client_secret": "{client_secret}",
"token": "{access_token}"
}
{}
The token is then revoked, and you can no longer use it to authenticate requests.
Basic authentication suits single user applications, such as a script that reads your own account.
Knowing your email and password, get an authentication token associated with your API key. This request needs only your API key, no authentication:
x-rwgps-api-key: {api_key}{
"user": {
"email": "{email}",
"password": "{password}"
}
}
{
"auth_token": {
"auth_token": "c0cc78875f250604f9abac97712e314c",
"api_key": "2704a8df",
"created_at": "2000-01-01T12:00:00Z",
"updated_at": "2000-01-01T12:00:00Z",
"user": {
"id": 123,
"email": "alex@example.com",
"name": "Alex Rider",
"created_at": "2000-01-01T12:00:00Z",
"updated_at": "2000-01-01T12:00:00Z"
}
}
}
If you use an organization account, you have no password, so you cannot use the endpoint above. See Authentication for organizations.
You can then authenticate with Basic authentication, using your api_key and auth_token:
// header
Authorization: Basic base64encode("{api_key}:{auth_token}")
With curl, pass -u "$API_KEY:$AUTH_TOKEN".
Alternatively, send them as headers:
// headers
x-rwgps-api-key: {api_key}
x-rwgps-auth-token: {auth_token}