CiscoDevNet / intersight-powershell

Cisco Intersight PowerShell
Apache License 2.0
16 stars 4 forks source link

Feature request: Add OAuth2 Client Credentials and access token use examples #170

Open dsoper2 opened 4 weeks ago

dsoper2 commented 4 weeks ago

Describe the bug Feature request to add support for OAuth2 Client Credentials and access token use examples

Additional context OAuth2 ClientId and ClientSecret can be used to generate an access (bearer) token with the following:

curl 'https://intersight.com/iam/token' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'grant_type=client_credentials' \ --data-urlencode 'client_id=46a7e36f289f9133bb1a15d154505a6093eaafa71314887df1427a8d45d7b526-636d24f77564612d3375a70f' \ --data-urlencode 'client_secret=d0b8bfa099cc1723e87e1d9aec361…'

Response:

{"access_token":"eyJh...pg","expires_in":600,"token_type":"Bearer"}

The token can then be used to authenticate with any API resource:

curl 'https://intersight.com/api/v1/iam/Users' --header 'Authorization: Bearer e...pg'

Response:

"ObjectType": "iam.User.List", "Results": [ { "AccountMoid": "636d24f77564612d3375a70e", "Ancestors": [ { "ClassId": "mo.MoRef", "Moid": "636d24f77564612d3375a711", "ObjectType": "iam.IdpReference", …

Request is to support in the module so that cmdlets can use Bearer tokens instead of API key based signing.