Generating OAuth2 Token in WSO2 APIM
First we need to create and publish an API in the APIM Publisher. Then Go to the store, subscribe an application to the API, and get the consumer key and consumer secret. Then execute the follow cURL command to generate the oAuth2 token.
curl -k -d "grant_type=password&username=admin&password=admin" -H "Authorization: Basic OXFhdUhUSjZoX0pkQUg2aDluOFZXWTV6NXQwYTpNZ0ZqTzQ4bW5OdzhVZHRkd1Bodkx1TDh5bWth, Content-Type: application/x-www-form-urlencoded" https://localhost:8243/token
Where OXFhdUhUSjZoX0pkQUg2aDluOFZXWTV6NXQwYTpNZ0ZqTzQ4bW5OdzhVZHRkd1Bodkx1TDh5bWth is the base64 encoded value of <consumer_key>:<consumer_secret>
The received token can be then used to invoke the above published API, Passing it in the header in the following format.
Authorization : Bearer <token>
0 comments