Skip to content

Commit 3e65c49

Browse files
authored
Merge pull request #656 from w0o/master
chore: Updated readme to provide information on generating IAM access tokens
2 parents 0193c9d + 09d7384 commit 3e65c49

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,20 @@ If you'd prefer to set authentication values manually in your code, the SDK supp
134134

135135
### IAM
136136

137-
IBM Cloud is migrating to token-based Identity and Access Management (IAM) authentication. IAM authentication uses a service API key to get an access token that is passed with the call. Access tokens are valid for approximately one hour and must be regenerated.
137+
IBM Cloud has migrated to token-based Identity and Access Management (IAM) authentication. IAM authentication uses a service API key to get an access token that is passed with the call. Access tokens are valid for approximately one hour and must be regenerated.
138138

139139
You supply either an IAM service **API key** or an **access token**:
140140

141141
- Use the API key to have the SDK manage the lifecycle of the access token. The SDK requests an access token, ensures that the access token is valid, and refreshes it if necessary.
142142
- Use the access token if you want to manage the lifecycle yourself. For details, see [Authenticating with IAM tokens](https://console.bluemix.net/docs/services/watson/getting-started-iam.html).
143+
- Use a server-side to generate access tokens using your IAM API key for untrusted environments like client-side scripts. The generated access tokens will be valid for one hour and can be refreshed.
144+
145+
### Generating access tokens using IAM API key
146+
```python
147+
# In your API endpoint use this to generate new access tokens
148+
iam_token_manager = IAMTokenManager(iam_apikey='<apikey>')
149+
token = iam_token_manager.get_token()
150+
```
143151

144152
#### Supplying the IAM API key
145153

0 commit comments

Comments
 (0)