positron
positron

Reputation: 3693

Executing wso2is REST API

I want to call wso2is Tenant API, but I cannot get correct authentication steps. I am generating access token using

curl -v -X POST -H "Authorization: Basic <auth>" -k -d "grant_type=password&username=admin&password=admin" -H "Content-Type:application/x-www-form-urlencoded" https://localhost:9443/oauth2/token

But not getting any response from the server when executing any of Tenant API endpoints.

Upvotes: 0

Views: 223

Answers (1)

Anuradha Karunarathna
Anuradha Karunarathna

Reputation: 3057

  1. Create a service provider and configure it as an OIDC client application. (1)

  2. Generate the access token using the following command.

curl -u <CLIENT_ID>:<CLIENT_SECRET> -k -d "grant_type=password&username=<USERNAME>&password=<PASSWORD>&scope=<REQUIRED_SCOPE>" -H "Content-Type:application/x-www-form-urlencoded" https://<IS-HOST>:<PORT>/oauth2/token

You have to replace <CLIENT_ID>, <CLIENT_SECRET>, <USERNAME>, <PASSWORD>, <REQUIRED_SCOPE>, <IS-HOST>, <PORT> accordingly. More Info: (2)

When adding the required scopes, look at the scopes required section of each endpoint in API definition. For example If you want to generate an access token to use in GET https://<HOST>:<PORT>/api/server/v1/tenants request's authorization, you should pass internal_list_tenants as a scope. Also you can pass multiple scopes separated by scapes.

  1. Use the retrieved access token to authorize the REST endpoint. If you generated the token without passing the required scopes, you will get 403 Forbidden response from the REST API call. More info (3)

Upvotes: 1

Related Questions