Generating Access Tokens using client credentials

Published on: 23-12-21 06:01pm

Himani Gupta

Veröffentlicht auf - 23-12-21 06:01pm

How to generate access tokens using client credentials?

You can use client credentials details to interact with the REST API of UVdesk using OAuth 2.0 standard. The client-server authentication model followed is as

per "The OAuth 2.0 Authorization Framework proposed in RFC 6749"

Where can you get client credentials?

Admin(s) can get API client credentials by Login into Admin Panel >> Search Api Client From Search bar >> Visit Api Client Page. You can Copy/Generate Client credentials details for API, from there.

UVdesk API supports Authorization Code grant, Password Grant, and Refresh Token grant.

 

Resource owner/Password Grant

The Password grant type (User Credentials/ Password Credentials) could be used to access data from UVdesk by providing client credentials directly.

Example Request:

Send credentials as given below to get Access token:

curl https://companydomain.uvdesk.com/oauth/v2/token -d 'client_id=TestClient&client_secret=TestSecret&grant_type=password&username=zondo&password=mypassword'

 

Authorization Code grant

First, redirect the user to the following URL: 

https://companydomain.uvdesk.com/en/member/oauth/v2/auth?response_type=code&client_id=123456789&redirect_uri=https://myredirecturi.com/route

Successful authorization will pass the authorization code in the URL via valid supplied redirect_uri:

https://myredirecturi.com/route?code=SplxlOBeZQQYbYS6WxSbIA&state=xyz

 
Use this code to request access token

https://companydomain.uvdesk.com/oauth/v2/token?client_id=TestClient&client_secret=TestSecret&grant_type=authorization_code&code=xyz&&redirect_uri=https://myredirecturi.com/route

 
Finally,  successful request will return access token in JSON format:

{"access_token":"f6c777d4dfae9c0d3b3c3503807cb390319339bd","expires_in":3600,"token_type":"bearer","scope":"API"}

 

Refresh Token Grant

Often Access Token have limited lifetime. In UVdesk, Access tokens have default lifetime of 2 months. To Increase lifetime of Access Tokens, corresponding refresh Tokens can be used.

Example Request:

curl https://companydomain.uvdesk.com/oauth/v2/token -d 'client_id=TestClient&client_secret=TestSecret&grant_type=refresh_token&refresh_token=G5QY2potGz3JOkF0XlKWIA'

Kann keine Antwort finden?

Auf der Suche nach etwas spezifischen Artikel, der in allgemeinen Fragen liegt? Stöbern Sie einfach die verschiedenen relevanten Ordner und Kategorien und dann finden Sie den gewünschten Artikel.

Kontaktiere uns

Aktion bestätigen

Bist du sicher? Sie wollen diese Aktion durchführen.