cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
krishnags
Responsive Resident
Responsive Resident

How to authenticate Google Sheets API using OAuth 2.0 from Power Automate?

I am new to Google Suit. As part of a requirement, we are trying to access Google Sheets from Microsoft Flows (Power Automate) using HTTP call. I have the details to access Google Sheets API such as client_id, client_secret and redirect_uri. It would be if any thoughts on the approach to achieve the authentication with the above details.

Scenario: We have some Google Sheets which holds data to be READ and WRITE Back.

I have tried calling Google Token API with below details, but getting an error

Error 400: invalid_request Required parameter is missing: response_type

Our main goal is to bypass user consent and authenticate Google APIs using client id and secret and perform the required actions on the data.

Steps performed to authenticate the Google API

Method: Get
URL: https://accounts.google.com/o/oauth2/auth 
Headers:
{
"client_id": "xxxxxxxxxxx-xxxxx0r0e4oe1dllujkiejtm7ii42jqk.apps.googleusercontent.com",

"redirect_uri": "https://console.cloud.google.com",

"response_type": "code",

"scope": "https://www.googleapis.com/auth/spreadsheets",

"access_type": "offline",

"prompt": "none"

}

I am following https://developers.google.com/identity/protocols/oauth2/web-server#httprest as a reference.

4 REPLIES 4
Jronash
Impactful Individual
Impactful Individual

Is that URL correct?  Looks like it should be https://accounts.google.com/o/oauth2/v2/auth.

 

If the URL isn't the issue, I'd go through your Headers JSON with a fine-toothed comb.  It's strange that the error message is saying that your response_type header is missing when it looks like it's right there.  Make sure all your quotes and commas are where they should be, and that everything is spelled correctly.

Jronash
Impactful Individual
Impactful Individual

Oh wait, I read too fast.  You're passing these as headers, but they're supposed to be query parameters.  See this example:

https://accounts.google.com/o/oauth2/v2/auth?
 scope=https%3A//www.googleapis.com/auth/drive.metadata.readonly&
 access_type=offline&
 include_granted_scopes=true&
 response_type=code&
 state=state_parameter_passthrough_value&
 redirect_uri=https%3A//oauth2.example.com/code&
 client_id=client_id

So it sounds like you can add all the parameters to the URL.

LFoundersMario
New Member

Did you manage to find a solution?

Love to hear this.

Mario

abm
Super User
Super User

Hi @krishnags , @LFoundersMario , @Jronash 

 

I have separated this into three tutorial videos.

 

Video Part 1 - How to obtain authorisation code?
https://youtu.be/LtH_VOax9DU

 

Video Part 2 - How to obtain access and refresh tokens?
https://youtu.be/MZN74noAB2w

 

Video Part 3 - How to obtain bearer token using refresh token and access Google Drive API using PowerAutomate?
https://youtu.be/TLZ2WpDE7U0

 


Please have a look and comment.



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (3,276)