Note: This authentication text applies to accessing specifically the Mobile Services Management API, which deviates from other APIs on the KPN API Store.

Authentication

Authentication is the process of proving your identity to the system. The KPN API Store uses the OAuth 2.0 Client Credentials Grant type: Client ID and Client secret.

To use the KPN APIs, you must obtain an access token (also called bearer token) by invoking our Authorization API using a POST method and sending the client credentials in the request.

URL: https://api-prd.kpn.com/oauth/grip/msm/accesstoken?grant_type=client_credentials


Authentication workflow

Authentication workflow


Where can I find my client credentials

Login into the KPN API Store.

  • Sandbox: Click on Sandbox to see your Client ID and Client secret for all APIs in the Sandbox. Use these credentials for testing.
  • Project: Click on a project in Projects to see your Client ID and Client secret for all APIs in that project. Use these credentials for your production applications.

Use them for authorization in SwaggerHub or when you send an API request to the KPN API Store, for example with Postman or in a cURL request. You will receive an access token in the JSON message body of the response.

For example: "access_token": "haf2SDl07E9N7RluNQ4kJ1TkGgso".


Authenticating using cURL

Execute the cURL command to receive an access token. Replace APP_CLIENT_ID and APP_CLIENT_SECRET with your credentials (Client ID and Client secret).

cURL for Linux and MacOS

curl -X POST \
 'https://api-prd.kpn.com/oauth/grip/msm/accesstoken?grant_type=client_credentials' \
 -H 'content-type: application/x-www-form-urlencoded' \
 -d 'client_id=APP_CLIENT_ID&client_secret=APP_CLIENT_SECRET'

cURL for Windows If you are using cURL for Windows, please use the command below instead.

curl -X POST "https://api-prd.kpn.com/oauth/grip/msm/accesstoken?grant_type=client_credentials" -H "content-type: application/x-www-form-urlencoded" -d "client_id=APP_CLIENT_ID&client_secret=APP_CLIENT_SECRET"

Response

The authentication service returns a JSON message that contains the access_token field.

Successful HTTP Status: 200
{
    "refresh_token_expires_in": "0",
    "api_product_list": "[xxxxxx]",
    "organization_name": "kpn",
    "developer_email": "demo123@kpn.com",
    "token_type": "Bearer",
    "issued_at": "1587458037687",
    "client_id": "APP_CLIENT_ID",
    "access_token": "staG765sBUuai4OMeZiTful6PTRt",
    "application_name": "test_application",
    "level": "demo",
    "scope": "",
    "expires_in": "3599",
    "refresh_token": "",
    "refresh_count": "0",
    "status": "approved"
}


Run this endpoint

You can easily run this and other endpoints.

  1. Go to the API on SwaggerHub.
  2. Click Authorize.
    1. Enter your client_id and client_secret using your KPN API Store credentials (Client ID and Client secret).
    2. Click Authorize.
    3. Click Close.
  3. Click an endpoint.
    1. Click Try it out.
    2. Enter/select all required parameter values and any optional parameter values.
    3. At the bottom of the form, click Execute.

Review the Response.

Authenticating using SwaggerHub

  1. Open the API reference of the API you want to use.
  2. Click on the Authorize button on the right.
  3. In the form, fill in client_id and client_secret, using your KPN API Store credentials (Client ID and Client secret).
  4. Click Authorize.

Note: Even if the button says Authorize, it's really the authentication process.


Authenticating using Postman

When using Postman, you will have to import the Swagger file into a Postman collection as follows:

  1. Open the API reference on SwaggerHub.
  2. On the top right, click Export, click Download API and click 'YAML Unresolved'.
  3. In Postman from the menu click File and click Import... Choose the YAML file you downloaded in the previous step. A new collection will be added.
  4. Select Get Access Token from the collection.
  5. Make sure the right environment is selected, corresponding to the API.
  6. Edit the environment variables client_id and client_secret, using your credentials (Client ID and Client secret).
  7. Check the response code and message.
  8. Press the Send button to get an access token.

Note: Request variables are no longer linked to an environment, but to the collection.

Mopinion feedback