'How can I migrate to an alternative flow (OAuth 2.0 for Desktop apps)?
I get authorization error, when trying connect my calendar to "Google" calendar. I added a photo of my problem.
How can I fix my code?
Here is my PHP code:
// Default data
$data = array(
'redirect_uri' => 'urn:ietf:wg:oauth:2.0:oob',
'scope' => 'https://www.googleapis.com/auth/calendar',
'access_type' => 'offline',
'response_type' => 'code',
'grant_type' => 'authorization_code',
'client_id' => '',
'client_secret' => '',
'code' => '',
'access_token' => '',
'refresh_token' => '',
);
And here is my JS code:
function gcal_access_link() {
var obj = {
client_id : jQuery('#client_id').val(),
response_type : 'code',
redirect_uri : 'urn:ietf:wg:oauth:2.0:oob',
scope : 'https://www.googleapis.com/auth/calendar',
access_type : 'offline',
};
return 'https://accounts.google.com/o/oauth2/auth?' + jQuery.param(obj);
}
jQuery('#access_link').attr( 'href', gcal_access_link() ); // insert on page load
jQuery('body').on('change', '#client_id', function() {
jQuery('#access_link').attr( 'href', gcal_access_link() );
});

I need help to fix my code.
Solution 1:[1]
change your redirect uri from urn:ietf:wg:oauth:2.0:oob to http://127.0.0.1
The authorization code will come back as before
http://127.0.0.1/?code=COPY_THIS_CODE.
If you dont have a web server running on that host you will see an error in the browser but the code should still be there.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | DaImTo |
