Page 1 of 1

Swagger Api and autorization using third part identity provider

Posted: Fri Mar 22, 2024 11:05 am
by KaosESP32
Hi all

My understanding in how to use the auth button on the swagger api is to use the login2 api to obtain the token to be included in the header of authorized (locked) apis.

My question is: How to obtain the key token using a third party (Google in my case) identity provider?. In that case, there is no password to be provided to login2 api and, therefore, I'm not able to obtain the security token.

Any help would be highly appreciated.

Cesc

Re: Swagger Api and autorization using third part identity provider

Posted: Thu Mar 28, 2024 11:45 am
by KaosESP32
Anyone? ESP Rainmaker guys?

Re: Swagger Api and autorization using third part identity provider

Posted: Thu Mar 28, 2024 12:50 pm
by Manali
For third party providers like Google, RainMaker leverages standard OAuth.

There are two steps involved in this:
1. Authorise:

Paste the below URL in browser and signin with your Google credentials. You will be redirected to redirect_uri and will receive a code as its query parameter.

https://3pauth.rainmaker.espressif.com/ ... lcome.html

2. Token:

Call the below token API with the code.

Code: Select all

   curl --location 'https://3pauth.rainmaker.espressif.com/oauth2/token' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data-urlencode 'client_id=1h7ujqjs8140n17v0ahb4n51m2' \
    --data-urlencode 'grant_type=authorization_code' \
    --data-urlencode 'code=<code>' \
    --data-urlencode 'redirect_uri=https://rainmaker-login-ui.s3.amazonaws.com/welcome.html'
You should get an accesstoken and refreshtoken in response. Done! :D

Subsequently, you can use the refreshtoken to extend session using the login2 API.

Ps. We are working on adding these details to the swagger document.
Manali

Re: Swagger Api and autorization using third part identity provider

Posted: Sun Mar 31, 2024 10:04 pm
by KaosESP32
Many Thanks Manali, it works! :D