Urban Sharing - Authentication API (1.1.0)

Download OpenAPI specification:

You can use the Authentication API to obtain Urban Sharing API authentication tokens. Tokens have a limited lifetime and must be refreshed at regular intervals. Before using the Authentication API, you must obtain API credentials from Urban Sharing. The API credentials include a Client ID and a Client Secret. Each client ID is valid for one Urban Sharing Fleet system and can be used to access multiple APIs. Which APIs are accessible depends on which roles you are granted. It is possible to request multiple client IDs for the same system if required.

Release History

DateVersionNotes
Thu Feb 15 20241.1.0Add OAuth endpoints
Renamed auth/token endpoint to auth/me
Tue Aug 15 20231.0.0Initial release

How to obtain an authentication token

To obtain an authentication token, send a POST request to http://auth.api.urbansharing.com/auth/token. This is the only endpoint that does not require a valid token in the Authorization header. All other API requests must include a valid token in the Authorization header. e.g.

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRJZCI6ImFwaV8xREhneXo3RHA0YkRYTXVJWktLb3hPMHkiLCJyb2xlcyI6WyJhcGkxIiwiYXBpMiJdLCJzeXN0ZW1JZCI6InRlc3Qtc3lzdGVtIiwiaWF0IjoxNjg4NjI4MDA4LCJleHAiOjE2ODg2MjkwMDh9.WtAnY1WR28U8NEZDePRpr-3UiHpTjB07GOXKp2dfeas

If the token is valid, the request will be processed. If the token is invalid, the request will be rejected with a 403 Forbidden response.

You can use curl to obtain a JWT token. Tokens expire after 60 minutes.
curl -X POST https://auth.api.urbansharing.com/auth/token \
  -H 'Content-Type: application/json' \
  -d '{ "grantType": "client_credentials", "clientId": "your_client_id", "clientSecret": "your_client_secret" }'

Implementing and authenticating Webhooks


Token

Bearer token request

An authentication token is required to access Urban Sharing APIs. To request a token, provide a valid client ID and client secret credentials. API credentials can be obtained from Urban Sharing.

Request Body schema: application/json
required
grantType
required
string
Value: "client_credentials"

Grant Type must always be "client_credentials"

clientId
required
string

A client ID can be obtained from Urban Sharing

clientSecret
required
string

A client secret can be obtained from Urban Sharing

Responses

Request samples

Content type
application/json
{
  • "grantType": "client_credentials",
  • "clientId": "client576576",
  • "clientSecret": "secret565ee65"
}

Response samples

Content type
application/json
{
  • "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
  • "tokenType": "Bearer",
  • "expiresIn": 3600,
  • "expiresAt": "2021-01-01T00:01:00.000Z"
}

OAuth Service Account login

Authenticate directly with service account credentials.

Request Body schema: application/json
required
accountId
required
string

The service account id

accountSecret
required
string

The service account secret

Responses

Request samples

Content type
application/json
{
  • "accountId": "asa_1234",
  • "accountSecret": "my-account-secret"
}

Response samples

Content type
application/json
{
  • "token": "eyJhbGciOiJIUz...36POk6yJV_adQssw5c"
}

OAuth

OAuth logout

Logs out the current user.

query Parameters
redirect
string
Example: redirect=https://www.urbansharing.com

The URL to redirect to after authentication.

Responses

OAuth IdToken login

Authenticate directly with an existing idtoken.

path Parameters
provider
required
string
Enum: "google" "microsoft"
Example: google

The OAuth provider to use for authentication.

Request Body schema: application/json
required
token
required
string

The third party id token, signed by the provider.

Responses

Request samples

Content type
application/json
{
  • "token": "eyJhbGciOiJIUz...36POk6yJV_adQssw5c"
}

Response samples

Content type
application/json
{
  • "token": "eyJhbGciOiJIUz...36POk6yJV_adQssw5c"
}

OAuth login

Redirects to the OAuth provider for authentication.

path Parameters
provider
required
string
Enum: "google" "microsoft"
Example: google

The OAuth provider to use for authentication.

query Parameters
redirect
required
string
Example: redirect=https://www.urbansharing.com

The URL to redirect to after authentication.

Responses

Auth

me

Returns data for the current authenticated user/token.

header Parameters
uowid
string

A globally unique unit of work ID generated by the client which allows Urban Sharing to track requests through our systems. If no header is provided it will be generated automatically at the time of arrival. The header and ID will be returned in the response.

Responses

Response samples

Content type
application/json
Example
{
  • "id": 0,
  • "sub": "api_1MpxBhayYfJP3r4p107i185E",
  • "role": "bearer",
  • "iat": 1700000000,
  • "exp": 1700000000,
  • "attrs": {
    }
}

Users Organization

Providers

List of available login providers for this organization

path Parameters
realm
required
string

The realm identifier

organizationId
required
string

The organization identifier

systemId
required
string

Responses

Response samples

Content type
application/json
{
  • "data": [
    ]
}

Logout

Logs out the current user.

path Parameters
organizationId
required
string

The organization identifier

realm
required
string

The realm identifier

query Parameters
redirect
string
Example: redirect=https://www.urbansharing.com

The URL to redirect to after authentication.

Responses

IdToken login

Authenticate directly with an existing idtoken.

path Parameters
realm
required
string

The realm identifier

organizationId
required
string

The organization identifier

provider
required
string
Enum: "google" "facebook" "microsoft" "apple" "phone" "email"

The OAuth provider type

Request Body schema: application/json
required
token
required
string

The third party id token, signed by the provider.

Responses

Request samples

Content type
application/json
{
  • "token": "eyJhbGciOiJIUz...36POk6yJV_adQssw5c"
}

Response samples

Content type
application/json
{
  • "token": "eyJhbGciOiJIUz...36POk6yJV_adQssw5c"
}

OAuth login

Redirects to the OAuth provider for authentication.

path Parameters
realm
required
string

The realm identifier

organizationId
required
string

The organization identifier

provider
required
string
Enum: "google" "facebook" "microsoft" "apple" "phone" "email"

The OAuth provider type

query Parameters
redirect
required
string
Example: redirect=https://www.urbansharing.com

The URL to redirect to after authentication.

Responses

OAuth signup

Redirects to the OAuth provider for authentication.

path Parameters
realm
required
string

The realm identifier

organizationId
required
string

The organization identifier

provider
required
string
Enum: "google" "facebook" "microsoft" "apple" "phone" "email"

The OAuth provider type

query Parameters
redirect
required
string
Example: redirect=https://www.urbansharing.com

The URL to redirect to after authentication.

Responses

SMS login

Initiates an SMS login flow. Returns a state token to be used with the verify endpoint.

path Parameters
realm
required
string

The realm identifier

organizationId
required
string

The organization identifier

Request Body schema: application/json
required
phoneNumber
required
string

The phone number to send the SMS code to.

Responses

Request samples

Content type
application/json
{
  • "phoneNumber": "+4712345678"
}

Response samples

Content type
application/json
{
  • "state": "eyJhbGciOiJIUz...36POk6yJV_adQssw5c"
}

SMS signup

Initiates an SMS signup flow. Returns a state token to be used with the verify endpoint.

path Parameters
realm
required
string

The realm identifier

organizationId
required
string

The organization identifier

Request Body schema: application/json
required
phoneNumber
required
string

The phone number to send the SMS code to.

Responses

Request samples

Content type
application/json
{
  • "phoneNumber": "+4712345678"
}

Response samples

Content type
application/json
{
  • "state": "eyJhbGciOiJIUz...36POk6yJV_adQssw5c"
}

SMS verify

Verifies the SMS code and completes the login or signup flow.

path Parameters
realm
required
string

The realm identifier

organizationId
required
string

The organization identifier

Request Body schema: application/json
required
state
required
string

The state returned from the SMS login/signup endpoint.

code
required
string

The SMS verification code.

Responses

Request samples

Content type
application/json
{
  • "state": "eyJhbGciOiJIUz...36POk6yJV_adQssw5c",
  • "code": "123456"
}

Response samples

Content type
application/json
{
  • "token": "eyJhbGciOiJIUz...36POk6yJV_adQssw5c"
}

UsersController_organizationOauthCallback

path Parameters
realm
required
string

The realm identifier

organizationId
required
string

The organization identifier

provider
required
string
Enum: "google" "facebook" "microsoft" "apple" "phone" "email"

The OAuth provider type

query Parameters
code
required
string
state
required
string

Responses

Users System

Providers

List of available login providers for this organization

path Parameters
realm
required
string

The realm identifier

organizationId
required
string

The organization identifier

systemId
required
string

The system identifier

Responses

Response samples

Content type
application/json
{
  • "data": [
    ]
}

Logout

Logs out the current user.

path Parameters
systemId
required
string

The system identifier

organizationId
required
string

The organization identifier

realm
required
string

The realm identifier

query Parameters
redirect
string
Example: redirect=https://www.urbansharing.com

The URL to redirect to after authentication.

Responses

IdToken login

Authenticate directly with an existing idtoken.

path Parameters
realm
required
string

The realm identifier

organizationId
required
string

The organization identifier

systemId
required
string

The system identifier

provider
required
string
Enum: "google" "facebook" "microsoft" "apple" "phone" "email"

The OAuth provider type

Request Body schema: application/json
required
token
required
string

The third party id token, signed by the provider.

Responses

Request samples

Content type
application/json
{
  • "token": "eyJhbGciOiJIUz...36POk6yJV_adQssw5c"
}

Response samples

Content type
application/json
{
  • "token": "eyJhbGciOiJIUz...36POk6yJV_adQssw5c"
}

OAuth login

Redirects to the OAuth provider for authentication.

path Parameters
realm
required
string

The realm identifier

organizationId
required
string

The organization identifier

systemId
required
string

The system identifier

provider
required
string
Enum: "google" "facebook" "microsoft" "apple" "phone" "email"

The OAuth provider type

query Parameters
redirect
required
string
Example: redirect=https://www.urbansharing.com

The URL to redirect to after authentication.

Responses

OAuth signup

Redirects to the OAuth provider for authentication.

path Parameters
realm
required
string

The realm identifier

organizationId
required
string

The organization identifier

systemId
required
string

The system identifier

provider
required
string
Enum: "google" "facebook" "microsoft" "apple" "phone" "email"

The OAuth provider type

query Parameters
redirect
required
string
Example: redirect=https://www.urbansharing.com

The URL to redirect to after authentication.

Responses

SMS login

Initiates an SMS login flow. Returns a state token to be used with the verify endpoint.

path Parameters
realm
required
string

The realm identifier

organizationId
required
string

The organization identifier

systemId
required
string

The system identifier

Request Body schema: application/json
required
phoneNumber
required
string

The phone number to send the SMS code to.

Responses

Request samples

Content type
application/json
{
  • "phoneNumber": "+4712345678"
}

Response samples

Content type
application/json
{
  • "state": "eyJhbGciOiJIUz...36POk6yJV_adQssw5c"
}

SMS signup

Initiates an SMS signup flow. Returns a state token to be used with the verify endpoint.

path Parameters
realm
required
string

The realm identifier

organizationId
required
string

The organization identifier

systemId
required
string

The system identifier

Request Body schema: application/json
required
phoneNumber
required
string

The phone number to send the SMS code to.

Responses

Request samples

Content type
application/json
{
  • "phoneNumber": "+4712345678"
}

Response samples

Content type
application/json
{
  • "state": "eyJhbGciOiJIUz...36POk6yJV_adQssw5c"
}

SMS verify

Verifies the SMS code and completes the login or signup flow.

path Parameters
realm
required
string

The realm identifier

organizationId
required
string

The organization identifier

systemId
required
string

The system identifier

Request Body schema: application/json
required
state
required
string

The state returned from the SMS login/signup endpoint.

code
required
string

The SMS verification code.

Responses

Request samples

Content type
application/json
{
  • "state": "eyJhbGciOiJIUz...36POk6yJV_adQssw5c",
  • "code": "123456"
}

Response samples

Content type
application/json
{
  • "token": "eyJhbGciOiJIUz...36POk6yJV_adQssw5c"
}

UsersWithSystemController_systemOauthCallback

path Parameters
realm
required
string

The realm identifier

organizationId
required
string

The organization identifier

systemId
required
string

The system identifier

provider
required
string
Enum: "google" "facebook" "microsoft" "apple" "phone" "email"

The OAuth provider type

query Parameters
code
required
string
state
required
string

Responses