-
Notifications
You must be signed in to change notification settings - Fork 0
oauth authorization code
Note: The Swisscom OAuth is only usable if it is approved and granted by the API team - contact us via the contact form.
This tutorial describes an easy way to get an OAuth authorization code & access token and shows the integration flow.
Tools:
- Google Chrome
- Modify Headers Plugin for google Chrome
- Localhost Server - How to setup a localhost server on Windows
Open this URL in the browser - you need a valid client id.
https://consent.swisscom.com/c/oauth2/auth?response_type=code&redirect_uri=https%3A%2F%2Flocalhost&client_id=%YOUR_CLIENT_ID%&lang=en
You will see the Swisscom login

The user has to login with his Swisscom Credentials (username and password).
After successful login a consent page appears with a request to agree that this page/app has the permission to read the users information.

It has to be configured with the API engineers what kind of information can be asked for, example: scope=read-basicprofile, read-birthdate etc. The browser redirects to the redirect URL (of step1) after confirming the consent page. The consent page will only appear if it was configured with an API engineer before. Otherwise the browser redirects to the redirect URL (of step1) directly.
In this example it is “5du16Pu6”
a) Set the Authorization header in the browser: Authorization: Basic %YOUR_CLIENT_ID%:%YOUR_CLIENT_ID_SECRET%(As BASE64) (OAuth) and enable it

https://consent.swisscom.com/o/oauth2/token?grant_type=authorization_code&code=5du16Pu6&redirect_uri=https%3A%2F%2Flocalhost
You should see the token in the JSON response.

NOTE: If you see 401 with “INVALID_AUTHENTICATION_CREDENTIALS” make sure that you set and enabled the Authentication header, see step (a).
In this example the token is: “kVhlBP24TjemCzvmSxSvkpa6ZUwv”
As example: Voice Voip Numbers as a curl call