Google Identity Platform: OAuth 2

Hello,

Does anyone already use the google Oauth 2.0 ?

I want to insert an event via api in google calendar but I need first to make a authentication request before inserting my event.

Unfortunately, I did not succeed to submit an authentication.
Any advise ?

Thx
pierre-yves

My fetch is:

const url = “Sign in - Google Accounts”;

const request = {
“redirect_uri”: “https://www.think4jet.com/test-html”,
“response_type”: “=code&”,
“client_id”: “MY_CLIENT_ID”,
“scope”: “https://www.googleapis.com/auth/calendar
};

return fetch(url, request); 
	.then(response => console.info(response.json()));

Hi,
Instead of using fetch() use wixLocation.to.

Construct the URL to google authentication servers using the variables you mentioned above and then redirect the site to Google for authentication using wixLocation.to

The URL should be something like:

https://accounts.google.com/o/oauth2/v2/auth?
 scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.metadata.readonly&
 include_granted_scopes=true&
 state=state_parameter_passthrough_value&
 redirect_uri=http%3A%2F%2Foauth2.example.com%2Fcallback&
 response_type=token&
 client_id=client_id
 
 //Taken from Google docs at https://developers.google.com/identity/protocols/OAuth2UserAgent

Next, you’d need to use wixLocation.url to get the token from the page Google redirects the site.

Hi shay,
Thanks for your help!
I am losing my head on that particular issue, spending days without real progress ;(

I’ve got 2 questions regarding your proposal:
1- Do you think the https://accounts.google.com/o/oauth2/v2/auth ? Is the correct one ?
I am thinking it should be an api address ? like https://www.googleapis.com ?
I did not find in the doc if it is correct

2 – Do you know how the redirect_uri parameter is working ?
I tried with yours but I’ve got the error: Error: redirect_uri_mismatch
In the google api console, I removed “Authorized redirect URIs”. Not sure this is the correct choice…

Thanks
Pierre-yves

I am not sure. Look into クライアントサイド ウェブ アプリケーション用の OAuth 2.0  |  Authorization  |  Google for Developers for more information. I based my sample on that article.

did it work? Can we see the code you used?

Hi sir,

Can you help me with my problem? Actually, I don’t really know how to use Wix. I want to force visitors to sign up when they visit my webpage. If visitors don’t sign up when accessing my site, it should automatically redirect to Google OAuth2, like the attached image below. After signing up, it should auto-redirect back to my site. Additionally, I want to save the visitors’ email and full name to a database.
Hoping for your response.

Thanks