oauth scopes.html - swisscom-api/doc GitHub Wiki


title: OAuth Scopes owner: API

<%= modified_date %>

What are scopes?

APIs can be protected by OAuth access tokens. Every request to such API must contain a valid access token in the header, like this:

Authentication: Bearer AH5ht9HOQQPypHF04vwGGQfljoPy

Most Swisscom user data is protected by scopes (permissions) in addition to OAuth authorization. Each access token has an associated set of scopes. Each scope represents a permission that the token owner has been granted.

OAuth scopes let you define which parts of user data your app needs to access. As an app developer, you can specify your desired scopes in the initial OAuth authorization request. When a user is responding to your OAuth request, the requested scopes will be displayed to them when they are asked to approve your request.

Types of scopes

Currently there are only two classes of action:

  • read: reading the information about particular resource
  • write: any modification related to particular resource

Examples of scopes for the swisscom APIs are:

  • read-basicprofile
  • read-phone/read-email
  • read-voip-callforwardings
  • write-voip-callforwardings

How to use scopes?

During the initial OAuth authorization request process, you can specify desired scopes separated by space: scope=write-voip-callforwardings%20read-voip-callforwardings

An example of OAuth authorization request with specified scope

https://consent.swisscom.com/c/oauth2/auth?response_type=code&redirect_uri=https%3A%2F%2Flocalhost&client_id=%YOUR_CLIENT_ID%&lang=en&scope=write-voip-callforwardings%20read-voip-callforwardings

An example response with requested scopes

{
    "access_token": "KASDFHDASHFSASHAS_DHAISDHFSAIDS",
    "scope": "write-voip-callforwardings read-voip-callforwardings",
    "token_type": "bearer",
    "expires_in": "2591999"
}
⚠️ **GitHub.com Fallback** ⚠️