Path: blob/main/L4assets/DSandMLOpsAssets/CLIandSDK/Notebooks/CPDaaS-01 IAM Authentication.ipynb
1928 views
Identity Access Management
API documentation:
IAM identity services
This documentation includes API description for Java, Node, Python, and Go interfaces
The functionality demonstrated includes:
Defining Python function for REST API calls
Bearer token generation and header file definition
Get the details of the API key using the REST API
Get some key details using the Python interface
Get a specific API key details using its id through the Python interface
Get the account configuration using the REST API
Get the account configuration using the Python interface
Preparation
Don't forget to generate an API key and update the API_key variable in the cell below.
In some cases, we are using both the REST API and the equivalent Python library.
Support functions
Generate the access token/bearer key
The token needs to be regenerated every hour
Other ways to generate an access token
Using username/password: only works for non-federated IBMid users (what does that mean?)
Using an authorization policy. Typically used for access between services
Create a access token and a delegated refresh token for an API key
Create a non-opaque access token without a refresh token for a Trusted Profile
Get the details of the API key
This will give us additional information such as:
account ID
Identity of the user (iam_id)
These values are needed for some of the calls.
Retrieve some API key details using the Python library
This is not equivalent to the previous call.
list_api_keys: Get a list of the API keys for this account. The default returns up to 20 keys.
The maximum number of keys returned is 100. To get more results, additional calls have to be made.get_api_key: retrieve the details of a specific API key using itsidwhich is different from the key itself
Get the account configuration
Author
Jacques Roy is a member of the IBM Enablement for Data and AI
Copyright © 2023. This notebook and its source code are released under the terms of the MIT License.