Using REST APIs
This section explains how you can use REST APIs.
-
Create a user.
To create a new user, see Adding Users procedure in Managing Users.
-
Call auth REST API to create a token.
Encode the username and password with base 64. Fill the encode output into the Authentication Header.
The following is a sample configuration to use REST API:
User: admin Password: bell Get the Base64 under Linux: echo -n 'admin:lab' | base64 Base64 encode output: YWRtaW46bGFi curl -X POST "https://{hostname}/api/auth/v1/token" -H "accept: application/json" -H "authorization: Basic YWRtaW46bGFi" Response code: 201 Response body { "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYXBpLWFkbWluIiwic2FsdCI6IlViQ2daamt IWHd6RUNzS1EiLCJleHAiOjE1NjQ2NTA2MTd9.x7ccHcOn6fLvHc_ajLJxQEY1ftvR1ZaJH9K_YZx1ues", "refresh_token": "lYYtZqgVhnsnBJgSHbigRzeEaLnWziMpHJKVzgHA", "refresh_token_expire": 1567221017, "token_type": "jwt" }
-
You can use the
access_token
created in the previous step to make individual REST API calls.The following is a sample configuration to make individual REST API calls, with user as
access_token
with headerAuthorization: Bearer
.curl -X GET https://{hostname}/api/rbac/v1/identitymgmt/user -H "accept: application/json" -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwicm9sZSI6ImxpLWFkbWlufGFwaS12aWV3ZXJ8YXBpLWVkaXRvcnxhcGktYWRtaW4 iLCJzYWx0IjoiZU9ZR0RtRFBsVFVwaEg1WCIsImV4cCI6MTY4MTc3Nzg2NCwic3ViIjoiYWRtaW4ifQ.gYIFghIusN4uN6ok0Ey8sANPTqRw_VcWmvtqklzkNDU" -k { "userDetailList": [ { "groupList": [ "admin", "api-admin", "api-editor", "api-viewer" ], "username": "admin", "passwordExpiryPeriod": "90" } ] }