So with the help of my team member Pushpalanka, I found an alternate way to get an access token by simply using a browser redirect and a curl command. So I wanted to make a note in case someone wanted to do the same :)
1. First, log in to the Identity Server management console.
the defaults are,
username = admin
username = admin
password = admin
https://localhost:9443/oauth2/authorize?response_type=code&client_id=<cliend_id>&redirect_uri=https://localhost/callback&scope=read
3. Go to the Inbound Authentication Configuration setting and enable OAuth/OpenID connect
4. Provide the callback_url as "https://localhost/callback"
5. You can type the following in a browser (better to try in an incognito/private window)
https://localhost:9443/oauth2/authorize?response_type=code&client_id=<cliend_id>&redirect_uri=https://localhost/callback&scope=read
6. You will be prompted to log in and thereafter approve to authorize the SP
you can use the same account you used to log in or any other valid user from the same tenant. (If u you want to allow users from other domains you need to enable SaaS enabled in the Service Provider Inbound Authenticator OAuth configuration)
7. Once you do that you will be redirected and you can find the code in the browser.
8. Copy the code value and use the CURL command below to send a request to the token endpoint to get an access token
curl -k -v --user <client_id>:<client_secret> -d "grant_type=authorization_code&code=<authorization_code>&redirect_uri=https://localhost/callback" https://localhost:9443/oauth2/token
9. You will get the access_token in the terminal like below,
{"access_token":"22630eaee65fef254e9cd099a96cf793","refresh_token":"ef18653c6b109887d66356254abd09fb","scope":"read","token_type":"Bearer","expires_in":3600}
{"access_token":"22630eaee65fef254e9cd099a96cf793","refresh_token":"ef18653c6b109887d66356254abd09fb","scope":"read","token_type":"Bearer","expires_in":3600}
love your lazy :D
ReplyDelete