Skip to content

Authentication (OAuth 2.0)

When your app wants to work with our API, it needs to be authenticated. We’ve made this easy with an OAuth 2.0 flow, so you don’t need to exchange API keys with the campsite.

Every widget and your app’s default page receive an ?authtoken=.... parameter. You exchange this auth token for an idToken and a refreshToken.

Example request

Terminal window
curl --location --request POST 'https://api.camping.care/v21/oauth/token' \
--form 'auth_token="..."'

Example response

{
"kind":"identitytoolkit#VerifyCustomTokenResponse",
"idToken":"....JWTidToken",
"refreshToken":"....RefreshToken",
"expiresIn":"3600",
"isNewUser":false
}

You can now use the idToken to call the API by sending it as a Bearer token. The request below gets the data of the user who is logged in via OAuth 2.0.

Example request

Terminal window
curl --location --request GET 'https://api.camping.care/v21/users/me' \
-H "Accept: application/json" \
-H "Authorization: Bearer {idToken}" \
-H "x-admin-id: {adminId}"

Every JWT idToken is valid for one hour (3600 seconds). When it expires, use the refresh token endpoint to get a new idToken you can use to authenticate with the API.

Example request

Terminal window
curl --location --request POST 'https://api.camping.care/v21/oauth/refresh_token' \
--form 'refresh_token="..."'

Example response

{
"access_token":"...AccessToken",
"expires_in":"3600",
"token_type":"Bearer",
"refresh_token":"...reFreshToken",
"id_token":"....idToken",
"user_id":"...userUid"
}