Answer the question
In order to leave comments, you need to log in
What is my mistake when authorizing google via oauth2?
I need to set up integration with google calendar. To do this, I found out you need to get a refresh_token from google. Through it, I can get an access token. And then work through the api.
To get a refresh_token, I form the following link [link 1]
https://accounts.google.com/o/oauth2/auth?response_type=code&redirect_uri={url}&client_id={client_id}&scope=https://www.googleapis.com/auth/calendar&access_type=offline&approval_prompt=auto
Answer the question
In order to leave comments, you need to log in
If it immediately redirects to {url}, then it means that it sees that you have already given access, and therefore does not request it. It will redirect to {url} and also pass $_GET['code'] as a parameter. Here you need to get a token through a post request to ' https://accounts.google.com/o/oauth2/token ' with parameters
$params = array(
'client_id' => 'application id',
'client_secret' => 'application secret',
'redirect_uri' => 'redirect url',
'grant_type' => 'authorization_code',
'code' => $_GET['code']
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question