Skip to content

OIDC

Latest
Compare
Choose a tag to compare
@korvalanni korvalanni released this 06 Feb 13:22
c1d5f86

Using DiadocApi with OIDC Authentication

To interact with the Diadoc API using OpenID Connect (OIDC) authentication, you need to provide an implementation of the TokenProvider interface. You can either use the built-in ContainerTokenProvider or implement your own token provider.

Code Example: Initializing DiadocApi

 var provider = new ContainerTokenProvider();
 provider.setToken(token);
 var api = new DiadocApi(provider, your_url, your_proxy_host, your_connection_settings);

How to get access_token

1. Register the Application

Register the application in the Integrator's Cabinet by following the instructions.

2. Authorize the User

Authorize the user via https://identity.kontur.ru/connect/authorize, using the appropriate clientId and scope for further actions.

  • PublicAPI grants access to the production environment.
  • Diadoc.PublicAPI.Staging grants access to the testing environment.

Example request:

curl \
    --data-urlencode "response_type=code id_token" \
    -d "client_id=YourClientId" \
    --data-urlencode "scope=openid profile email Diadoc.PublicAPI" \
    --data-urlencode "redirect_uri=YourUrl" \
    -d "nonce=0S6_WzA2MjrtsedfghfgtgYthFG_fgh" \
    -v \
    --get \
    "https://identity.kontur.ru/connect/authorize"
  1. Use code or jwt token from the response of the previous step. Obtain the access_token from identity.kontur.ru/connect/token.

Example request:

curl \
    -d "client_id=YourClientId" \
    -d "client_secret=YourSecret" \
    -d "grant_type=authorization_code" \
    -d "code=YourAuthCode" \
    -d "redirect_uri=YourUrl" \
    -v \
    "https://identity.kontur.ru/connect/token"