OAuth API documentation
https://consent.swisscom.com/
/c/oauth2
Used to obtain the authorization codes (OAuth 3-legged) or the access token (implicit 2-legged)
Used to obtain the authorization codes or the access token (implicit)
get /c/oauth2/auth
Used to obtain the authorization codes or the access token (implicit)
Query Parameters
- response_type: required (string)
"code" to get the authorization code or "token" to get the access token directly (implicit)
- redirect_uri: required (string)
It redirects to this URI after sending the request.
Has to be url encoded - client-id: required (string)
Identifies the client by its client_id.
HTTP status code 302
Moved Temporarly
HTTP status code 400
Invalid parameter.
Body
Type: application/json
Schema:
{
"$schema": "http://json-schema.org/draft-03/schema",
"type": "object" ,
"properties": {
"uuid": {
"description": "The UUID of the client software",
"type": "string",
"required" : "false"
},
"status": {
"description": "The http status code",
"type": "string",
"required": true
},
"code": {
"description": "The error code",
"type": "string",
"required": true
},
"message": {
"description": "The error message",
"type": "string",
"required": true
},
"detail": {
"description": "The error detail",
"type": "string",
"required": false
},
"error": {
"description": "The error, according to the OAuth 2.0 standard",
"type": "string",
"required": false
}
}
}
Example:
{
"status": "400",
"code": "INVALID_PARAMETER",
"message": "The request could not be understood due to malformed syntax. Correct the request syntax and try again.",
"detail": "Missing or invalid response_type, missing or invalid redirect_uri",
"error": "invalid_grant"
}
HTTP status code 401
Invalid parameter.
Body
Type: application/json
Schema:
{
"$schema": "http://json-schema.org/draft-03/schema",
"type": "object" ,
"properties": {
"uuid": {
"description": "The UUID of the client software",
"type": "string",
"required" : "false"
},
"status": {
"description": "The http status code",
"type": "string",
"required": true
},
"code": {
"description": "The error code",
"type": "string",
"required": true
},
"message": {
"description": "The error message",
"type": "string",
"required": true
},
"detail": {
"description": "The error detail",
"type": "string",
"required": false
},
"error": {
"description": "The error, according to the OAuth 2.0 standard",
"type": "string",
"required": false
}
}
}
Example:
{
"status": "401",
"code": "UNAUTHORIZED",
"message": "...",
"detail": "In case of unsuccessful authentication",
"error": "invalid_grant"
}
/o/oauth2
Used for obtaining access token (authorization code grant), refreshing token, revoking token, obtaining token information.
Used for obtaining access token and sometimes also a refresh token with authorization code grant.
Used for obtaining access token and sometimes also a refresh token with authorization code, refresh token, or client credentials grant.
get /o/oauth2/token
Used for obtaining access token and sometimes also a refresh token with authorization code grant.
Headers
- Authorization: required (string)
Identifies the App with client_id and client_secret. They must be separated by colon and base64 encoded.
Example:
Basic cXdlcnR5OmFzZGY=
Query Parameters
- grant_type: required (string)
"authorization_code" to get access and refresh tokens with a code. ("refresh_token" or "client_credentials" must use the POST method instead).
- code: (string)
Required if grant_type="authorization_code". The code obtained by the user after consent.
- redirect_uri: (string)
Required if grant_type="authorization_code". The redirect_uri parameter given as input during consent (exact match needed).
HTTP status code 200
Body
Type: application/json
Schema:
{
"$schema": "http://json-schema.org/draft-03/schema",
"type": "object",
"properties": {
"access_token": {
"description": "The Access Token.",
"type": "string",
"required":true
},
"refresh_token": {
"description": "Refresh Token. Depends on app/product configuration whether present.",
"type": "string",
"required":false
},
"expires_in": {
"description": "Time in seconds indicating for how long the access token will be valid. Time depends on app/product configuration.",
"type": "string",
"required":true
},
"token_type": {
"description": "Token type. E.g., bearer",
"type": "string",
"required":true
}
}
}
Example:
{
"access_token" : "2YotnFZFEjr1zCsicMWpAA",
"refresh_token" : "tGzv3JOkF0XG5Qx2TlKWIA",
"token_type" : "bearer",
"expires_in" : "3600"
}
HTTP status code 400
Invalid parameter.
Body
Type: application/json
Schema:
{
"$schema": "http://json-schema.org/draft-03/schema",
"type": "object" ,
"properties": {
"uuid": {
"description": "The UUID of the client software",
"type": "string",
"required" : "false"
},
"status": {
"description": "The http status code",
"type": "string",
"required": true
},
"code": {
"description": "The error code",
"type": "string",
"required": true
},
"message": {
"description": "The error message",
"type": "string",
"required": true
},
"detail": {
"description": "The error detail",
"type": "string",
"required": false
},
"error": {
"description": "The error, according to the OAuth 2.0 standard",
"type": "string",
"required": false
}
}
}
Example:
{
"status": "400",
"code": "INVALID_REFRESH_TOKEN",
"message": "Refresh token is invalid.",
"detail": "Refresh token is invalid, expired, revoked, was already refreshed, or was issued to another client.",
"error": "invalid_grant"
}
HTTP status code 401
Invalid parameter.
Body
Type: application/json
Schema:
{
"$schema": "http://json-schema.org/draft-03/schema",
"type": "object" ,
"properties": {
"uuid": {
"description": "The UUID of the client software",
"type": "string",
"required" : "false"
},
"status": {
"description": "The http status code",
"type": "string",
"required": true
},
"code": {
"description": "The error code",
"type": "string",
"required": true
},
"message": {
"description": "The error message",
"type": "string",
"required": true
},
"detail": {
"description": "The error detail",
"type": "string",
"required": false
},
"error": {
"description": "The error, according to the OAuth 2.0 standard",
"type": "string",
"required": false
}
}
}
Example:
{
"status": "401",
"code": "INVALID_REFRESH_TOKEN",
"message": "Refresh token is invalid.",
"detail": "Refresh token is invalid, expired, revoked, was already refreshed, or was issued to another client.",
"error": "invalid_grant"
}
HTTP status code 404
Not Found. The server has not found anything matching the Request-URI.
Body
Type: application/json
Schema:
{
"$schema": "http://json-schema.org/draft-03/schema",
"type": "object" ,
"properties": {
"uuid": {
"description": "The UUID of the client software",
"type": "string",
"required": false
},
"status": {
"description": "The http status code, e.g. 400",
"type": "string",
"required": true
},
"code": {
"description": "The error code, e.g. INVALID_PARAMETER",
"type": "string",
"required": true
},
"message": {
"description": "The error message",
"type": "string",
"required": true
},
"detail": {
"description": "The error detail",
"type": "string",
"required": false
}
}
}
Example:
{
"status": "404",
"code": "INVALID_REQUEST_RESOURCE",
"message": "The requested resource does not exist. Verify that the resource URI is correctly spelled.",
"detail": ""
}
HTTP status code 405
Method Not Allowed. The resource is not accessible via the given method. For example, the client sent a POST request to a resource that only implements GET.
Body
Type: application/json
Schema:
{
"$schema": "http://json-schema.org/draft-03/schema",
"type": "object" ,
"properties": {
"uuid": {
"description": "The UUID of the client software",
"type": "string",
"required": false
},
"status": {
"description": "The http status code, e.g. 400",
"type": "string",
"required": true
},
"code": {
"description": "The error code, e.g. INVALID_PARAMETER",
"type": "string",
"required": true
},
"message": {
"description": "The error message",
"type": "string",
"required": true
},
"detail": {
"description": "The error detail",
"type": "string",
"required": false
}
}
}
Example:
{
"status": "405",
"code": "INVALID_REQUEST_METHOD",
"message": "The resource is not accessible via the given method. Check the documentation or the Allow header for allowed methods.",
"detail": ""
}
post /o/oauth2/token
Used for obtaining access token and sometimes also a refresh token with authorization code, refresh token, or client credentials grant.
Headers
- Authorization: required (string)
Identifies the App with client_id and client_secret. They must be separated by colon and base64 encoded.
Example:
Basic cXdlcnR5OmFzZGY=
Body
Type: application/x-www-form-urlencoded
Form Parameters- grant_type: required (string)
"authorization_code" to get access and refresh tokens with a code. "refresh_token" to get access and refresh tokens with a refresh token. "client_credentials" to get an access token with client credentials grant.
- refresh_token: (string)
Required if grant_type="refresh_token". The refresh token.
- code: (string)
Required if grant_type="authorization_code". The code obtained by the user after consent.
- redirect_uri: (string)
Required if grant_type="authorization_code". The redirect_uri parameter given as input during consent.
- scope: (string)
Space-separated list of scopes, if it is desired to grant less scopes than configured for the app.
HTTP status code 200
Body
Type: application/json
Schema:
{
"$schema": "http://json-schema.org/draft-03/schema",
"type": "object",
"properties": {
"access_token": {
"description": "The Access Token.",
"type": "string",
"required":true
},
"refresh_token": {
"description": "Refresh Token. Depends on configuration whether present. Never given out if client credentials grant type.",
"type": "string",
"required":false
},
"expires_in": {
"description": "Time in seconds indicating for how long the access token will be valid.",
"type": "string",
"required":true
},
"token_type": {
"description": "Token type. E.g., bearer",
"type": "string",
"required":true
}
}
}
Example:
{
"access_token" : "2YotnFZFEjr1zCsicMWpAA",
"refresh_token" : "tGzv3JOkF0XG5Qx2TlKWIA",
"token_type" : "bearer",
"expires_in" : "3600"
}
HTTP status code 400
Invalid parameter.
Body
Type: application/json
Schema:
{
"$schema": "http://json-schema.org/draft-03/schema",
"type": "object" ,
"properties": {
"uuid": {
"description": "The UUID of the client software",
"type": "string",
"required" : "false"
},
"status": {
"description": "The http status code",
"type": "string",
"required": true
},
"code": {
"description": "The error code",
"type": "string",
"required": true
},
"message": {
"description": "The error message",
"type": "string",
"required": true
},
"detail": {
"description": "The error detail",
"type": "string",
"required": false
},
"error": {
"description": "The error, according to the OAuth 2.0 standard",
"type": "string",
"required": false
}
}
}
Example:
{
"status": "400",
"code": "INVALID_REFRESH_TOKEN",
"message": "Refresh token is invalid.",
"detail": "Refresh token is invalid, expired, revoked, was already refreshed, or was issued to another client.",
"error": "invalid_grant"
}
HTTP status code 401
Invalid parameter.
Body
Type: application/json
Schema:
{
"$schema": "http://json-schema.org/draft-03/schema",
"type": "object" ,
"properties": {
"uuid": {
"description": "The UUID of the client software",
"type": "string",
"required" : "false"
},
"status": {
"description": "The http status code",
"type": "string",
"required": true
},
"code": {
"description": "The error code",
"type": "string",
"required": true
},
"message": {
"description": "The error message",
"type": "string",
"required": true
},
"detail": {
"description": "The error detail",
"type": "string",
"required": false
},
"error": {
"description": "The error, according to the OAuth 2.0 standard",
"type": "string",
"required": false
}
}
}
Example:
{
"status": "401",
"code": "INVALID_REFRESH_TOKEN",
"message": "Refresh token is invalid.",
"detail": "Refresh token is invalid, expired, revoked, was already refreshed, or was issued to another client.",
"error": "invalid_grant"
}
HTTP status code 404
Not Found. The server has not found anything matching the Request-URI.
Body
Type: application/json
Schema:
{
"$schema": "http://json-schema.org/draft-03/schema",
"type": "object" ,
"properties": {
"uuid": {
"description": "The UUID of the client software",
"type": "string",
"required": false
},
"status": {
"description": "The http status code, e.g. 400",
"type": "string",
"required": true
},
"code": {
"description": "The error code, e.g. INVALID_PARAMETER",
"type": "string",
"required": true
},
"message": {
"description": "The error message",
"type": "string",
"required": true
},
"detail": {
"description": "The error detail",
"type": "string",
"required": false
}
}
}
Example:
{
"status": "404",
"code": "INVALID_REQUEST_RESOURCE",
"message": "The requested resource does not exist. Verify that the resource URI is correctly spelled.",
"detail": ""
}
HTTP status code 405
Method Not Allowed. The resource is not accessible via the given method. For example, the client sent a POST request to a resource that only implements GET.
Body
Type: application/json
Schema:
{
"$schema": "http://json-schema.org/draft-03/schema",
"type": "object" ,
"properties": {
"uuid": {
"description": "The UUID of the client software",
"type": "string",
"required": false
},
"status": {
"description": "The http status code, e.g. 400",
"type": "string",
"required": true
},
"code": {
"description": "The error code, e.g. INVALID_PARAMETER",
"type": "string",
"required": true
},
"message": {
"description": "The error message",
"type": "string",
"required": true
},
"detail": {
"description": "The error detail",
"type": "string",
"required": false
}
}
}
Example:
{
"status": "405",
"code": "INVALID_REQUEST_METHOD",
"message": "The resource is not accessible via the given method. Check the documentation or the Allow header for allowed methods.",
"detail": ""
}
HTTP status code 415
The request has a media type which the server or resource does not support. Please set the Content-Type header with a value supported by the API (e.g. application/json).
Body
Type: application/json
Schema:
{
"$schema": "http://json-schema.org/draft-03/schema",
"type": "object" ,
"properties": {
"uuid": {
"description": "The UUID of the client software",
"type": "string",
"required": false
},
"status": {
"description": "The http status code, e.g. 400",
"type": "string",
"required": true
},
"code": {
"description": "The error code, e.g. INVALID_PARAMETER",
"type": "string",
"required": true
},
"message": {
"description": "The error message",
"type": "string",
"required": true
},
"detail": {
"description": "The error detail",
"type": "string",
"required": false
}
}
}
Example:
{
"status": "415",
"code": "UNSUPPORTED_MEDIA_TYPE",
"message": "The request entity has a media type which the server or resource does not support. Please set the Content-Type header with a value supported by the API (e.g. application/json).",
"detail": ""
}
Used for obtaining information about an access or refresh token.
Used for obtaining information about an access or refresh token.
get /o/oauth2/token/info
Used for obtaining information about an access or refresh token.
The Swisscom API uses OAuth 2 for authentication. An authorization header containing a valid access_token must be included in every request.
Headers
- The Authorization OAuth2 Access Token: required (string)
The Authorization OAuth2 access token. The access token, which was retrieved through OAuth2 API, must be set after the Bearer string. The parameter is marked as {access_token}
Example:
Bearer {access_token}
HTTP status code 200
Body
Type: application/json
Schema:
{
"$schema": "http://json-schema.org/draft-03/schema",
"type": "object",
"properties": {
"type": {
"description": "Type. E.g., accesstoken",
"type": "string",
"required":true
},
"application_name": {
"description": "Application name",
"type": "string",
"required":true
},
"client_id": {
"description": "Indentifies the developer app.",
"type": "string",
"required":true
},
"scope": {
"description": "Scope for which the token is valid.",
"type": "string",
"required":true
},
"token_type": {
"description": "always bearer",
"type": "string",
"required":true
},
"issued_at": {
"description": "Timestamp when the token was issued (ISO 8601)",
"type": "string",
"required":true
},
"expires_in": {
"description": "Time when the token expires.",
"type": "string",
"required":true
},
"attributes": {
"description": "Attributes",
"type": "object",
"required":false,
"items" : {
"account_number" : {
"description": "BW Accountnumber",
"type": "string",
"required":true
},
"auth_level" : {
"description": "Authorization level",
"type": "string",
"required":true
},
"client_ip" : {
"description": "Client's IP address",
"type": "string",
"required":true
},
"scn" : {
"description": "Swisscom Customer Number",
"type": "string",
"required":true
},
"user_agent" : {
"description": "User agent",
"type": "string",
"required":true
},
"used_msisdn" : {
"description": "MSISDN",
"type": "string",
"required":true
},
"username" : {
"description": "Username",
"type": "string",
"required":true
},
"creator" : {
"description": "Attributes about the token creator",
"type": "object",
"required":true,
"items":{
"scn" : {
"description": "SCN of the creator of the access token. The creator is who requests an access token",
"type": "string",
"required":true
},
"accountNumber" : {
"description": "Account number of the creator. The creator is who requests an access token",
"type": "string",
"required":true
}
}
},
"payment" : {
"description" : "Attributes about the token creator",
"type" : "object",
"required" : true,
"items" : {
"clearingType" : {
"description": "Clearing type",
"type": "string",
"required":true
},
"clearingId" : {
"description": "Clearing Id",
"type": "string",
"required":true
},
"billSource" : {
"description": "Bill source",
"type": "string",
"required":true
},
"scn" : {
"description": "SCN for which this token grants access to.",
"type": "string",
"required":true
}
}
}
}
}
}
}
Example:
{
"type": "accesstoken",
"application_name" : "tokeninfo",
"client_id" : "U1B9XQwGJvGPOyiHHCXKMY6ZQ9sds",
"scope" : " a",
"token_type" : "bearer",
"issued_at" : "2014-07-08T11:52:57.653Z",
"expires_in" : "3599",
"attributes" : {
"account_number" : "1648110436",
"auth_level" : "30",
"client_ip" : "85.3.200.66",
"scn" : "55579262",
"user_agent" : "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0",
"used_msisdn" : "+41791234567",
"username" : "tester1234",
"creator" : {
"scn" : "1112223330",
"accountNumber": "yxcvyxcv"
},
"payment" : {
"clearingType" : "PN",
"clearingId" : "0041223334455",
"billSource" : "Mobile",
"scn" : "2223334440"
}
}
}
HTTP status code 400
Invalid parameter.
Body
Type: application/json
Schema:
{
"$schema": "http://json-schema.org/draft-03/schema",
"type": "object" ,
"properties": {
"uuid": {
"description": "The UUID of the client software",
"type": "string",
"required" : "false"
},
"status": {
"description": "The http status code",
"type": "string"
},
"code": {
"description": "The error code",
"type": "string"
},
"message": {
"description": "The error message",
"type": "string"
},
"detail": {
"description": "The error detail",
"type": "string",
"required": false
},
"error": {
"description": "The error, according to the OAuth 2.0 standard",
"type": "string",
"required": false
}
}
}
Example:
{
"status": "400",
"code": "INVALID_ACCESS_TOKEN",
"message": "Access token is invalid.",
"error": "invalid_request"
}
HTTP status code 401
Invalid authentication credeintials.
Body
Type: application/json
Schema:
{
"$schema": "http://json-schema.org/draft-03/schema",
"type": "object" ,
"properties": {
"uuid": {
"description": "The UUID of the client software",
"type": "string",
"required" : "false"
},
"status": {
"description": "The http status code",
"type": "string",
"required": true
},
"code": {
"description": "The error code",
"type": "string",
"required": true
},
"message": {
"description": "The error message",
"type": "string",
"required": true
},
"detail": {
"description": "The error detail",
"type": "string",
"required": false
},
"error": {
"description": "The error, according to the OAuth 2.0 standard",
"type": "string",
"required": false
}
}
}
Example:
{
"status": "401",
"code": "INVALID_AUTHENTICATION_CREDENTIALS",
"message": "Authentication credentials missing or incorrect. Check that you are using the correct authentication method and that you have permission to the given resource and your app key is approved",
"error": "invalid_client"
}
HTTP status code 404
Not Found. The server has not found anything matching the Request-URI.
Body
Type: application/json
Schema:
{
"$schema": "http://json-schema.org/draft-03/schema",
"type": "object" ,
"properties": {
"uuid": {
"description": "The UUID of the client software",
"type": "string",
"required": false
},
"status": {
"description": "The http status code, e.g. 400",
"type": "string",
"required": true
},
"code": {
"description": "The error code, e.g. INVALID_PARAMETER",
"type": "string",
"required": true
},
"message": {
"description": "The error message",
"type": "string",
"required": true
},
"detail": {
"description": "The error detail",
"type": "string",
"required": false
}
}
}
Example:
{
"status": "404",
"code": "INVALID_REQUEST_RESOURCE",
"message": "The requested resource does not exist. Verify that the resource URI is correctly spelled.",
"detail": ""
}
HTTP status code 405
Method Not Allowed. The resource is not accessible via the given method. For example, the client sent a POST request to a resource that only implements GET.
Body
Type: application/json
Schema:
{
"$schema": "http://json-schema.org/draft-03/schema",
"type": "object" ,
"properties": {
"uuid": {
"description": "The UUID of the client software",
"type": "string",
"required": false
},
"status": {
"description": "The http status code, e.g. 400",
"type": "string",
"required": true
},
"code": {
"description": "The error code, e.g. INVALID_PARAMETER",
"type": "string",
"required": true
},
"message": {
"description": "The error message",
"type": "string",
"required": true
},
"detail": {
"description": "The error detail",
"type": "string",
"required": false
}
}
}
Example:
{
"status": "405",
"code": "INVALID_REQUEST_METHOD",
"message": "The resource is not accessible via the given method. Check the documentation or the Allow header for allowed methods.",
"detail": ""
}
Headers
- Authorization: (string)
Used to send a valid OAuth 2 access token. Do not use together with the "access_token" query string parameter.
Used for revoking an access token.
Used for revoking an access token.
get /o/oauth2/token/revoke
Used for revoking an access token.
The Swisscom API uses OAuth 2 for authentication. An authorization header containing a valid access_token must be included in every request.
Headers
- The Authorization OAuth2 Access Token: required (string)
The Authorization OAuth2 access token. The access token, which was retrieved through OAuth2 API, must be set after the Bearer string. The parameter is marked as {access_token}
Example:
Bearer {access_token}
Query Parameters
- token: required (string)
The access token to be revoked.
HTTP status code 200
Token successfully revoked. Response body is empty.
HTTP status code 400
Invalid parameter.
Body
Type: application/json
Schema:
{
"$schema": "http://json-schema.org/draft-03/schema",
"type": "object" ,
"properties": {
"uuid": {
"description": "The UUID of the client software",
"type": "string",
"required" : "false"
},
"status": {
"description": "The http status code",
"type": "string",
"required": true
},
"code": {
"description": "The error code",
"type": "string",
"required": true
},
"message": {
"description": "The error message",
"type": "string",
"required": true
},
"detail": {
"description": "The error detail",
"type": "string",
"required": false
},
"error": {
"description": "The error, according to the OAuth 2.0 standard",
"type": "string",
"required": false
}
}
}
Example:
{
"status": "400",
"code": "INVALID_REFRESH_TOKEN",
"message": "Refresh token is invalid.",
"detail": "Refresh token is invalid, expired, revoked, was already refreshed, or was issued to another client.",
"error": "invalid_grant"
}HTTP status code 404
Not Found. The server has not found anything matching the Request-URI.
Body
Type: application/json
Schema:
{
"$schema": "http://json-schema.org/draft-03/schema",
"type": "object" ,
"properties": {
"uuid": {
"description": "The UUID of the client software",
"type": "string",
"required": false
},
"status": {
"description": "The http status code, e.g. 400",
"type": "string",
"required": true
},
"code": {
"description": "The error code, e.g. INVALID_PARAMETER",
"type": "string",
"required": true
},
"message": {
"description": "The error message",
"type": "string",
"required": true
},
"detail": {
"description": "The error detail",
"type": "string",
"required": false
}
}
}
Example:
{
"status": "404",
"code": "INVALID_REQUEST_RESOURCE",
"message": "The requested resource does not exist. Verify that the resource URI is correctly spelled.",
"detail": ""
}
HTTP status code 405
Method Not Allowed. The resource is not accessible via the given method. For example, the client sent a POST request to a resource that only implements GET.
Body
Type: application/json
Schema:
{
"$schema": "http://json-schema.org/draft-03/schema",
"type": "object" ,
"properties": {
"uuid": {
"description": "The UUID of the client software",
"type": "string",
"required": false
},
"status": {
"description": "The http status code, e.g. 400",
"type": "string",
"required": true
},
"code": {
"description": "The error code, e.g. INVALID_PARAMETER",
"type": "string",
"required": true
},
"message": {
"description": "The error message",
"type": "string",
"required": true
},
"detail": {
"description": "The error detail",
"type": "string",
"required": false
}
}
}
Example:
{
"status": "405",
"code": "INVALID_REQUEST_METHOD",
"message": "The resource is not accessible via the given method. Check the documentation or the Allow header for allowed methods.",
"detail": ""
}
Headers
- Authorization: (string)
Used to send a valid OAuth 2 access token. Do not use together with the "access_token" query string parameter.