Swagger Api and autorization using third part identity provider

KaosESP32
Posts: 13
Joined: Tue Oct 31, 2023 9:17 am

Swagger Api and autorization using third part identity provider

Postby KaosESP32 » Fri Mar 22, 2024 11:05 am

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

KaosESP32
Posts: 13
Joined: Tue Oct 31, 2023 9:17 am

Re: Swagger Api and autorization using third part identity provider

Postby KaosESP32 » Thu Mar 28, 2024 11:45 am

Anyone? ESP Rainmaker guys?

Manali
Posts: 3
Joined: Mon Jun 26, 2023 12:50 pm

Re: Swagger Api and autorization using third part identity provider

Postby Manali » Thu Mar 28, 2024 12:50 pm

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

KaosESP32
Posts: 13
Joined: Tue Oct 31, 2023 9:17 am

Re: Swagger Api and autorization using third part identity provider

Postby KaosESP32 » Sun Mar 31, 2024 10:04 pm

Many Thanks Manali, it works! :D

Who is online

Users browsing this forum: No registered users and 6 guests