Can't retrieve token with code when using one-time code flow.
See original GitHub issue var code = req.body.code;
var oauth2Client = new gapis.OAuth2Client(CLIENT_ID, CLIENT_SECRET, REDIRECT_URL);
oauth2Client.getToken(code, function(err, tokens) {
oauth2Client.setCredentials(tokens);
callback.call();
});
I’m sure of that all the three parameters of new OAuth2Client()
are correct, but still got a redirect_uri_mismatch
error.
Issue Analytics
- State:
- Created 10 years ago
- Comments:6
Top Results From Across the Web
Call Your API Using the Authorization Code Flow - Auth0
This tutorial will help you call your own API using the Authorization Code Flow. If you want to learn how the flow works...
Read more >ruby - Rails 4 - Google One Time Code Flow with omniauth ...
Refresh Token used to get a new access token when it expires. good until the user removes access. Authorization code. This is the...
Read more >How to get an access token with Auth Code Grant | DocuSign
This topic demonstrates how to manually generate an access token using Authorization Code Grant authentication or with a refresh token. In the Authorization ......
Read more >Getting error while getting access token using OAuth 2.0 ...
Getting error while getting access token using OAuth 2.0 device code flow. I am trying to get access token via OAuth 2.0 device ......
Read more >The Authorization Code grant (in excruciating detail) Part 2 of 2
This is one time use. The code is sent in the URL of a redirect. What is the target redirect URL? It is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
How awesome that this is undocumented.
if you want to use one-time code flow, the login button should look like following. <span id="login" class="g-signin" data-height="short" data-callback="loginToGoogle" data-cookiepolicy="single_host_origin" data-scope="https://www.googleapis.com/auth/userinfo.email" data-clientid="this attribute is set by javascript :)" data-accesstype="offline" data-redirecturi="postmessages">
see data-accesstype and data-redirectuir attributes.
and in your node source, you must create oauth2client like this. var oauth2Client = new googleapis.OAuth2Client( gooClientId, gooClientSecret, ‘postmessage’);
redirect uri argument must be ‘postmessage’ which is undocumented.
oauth2client.getToken(token, function(err, token) { oauth2client.setCredentials(token); //now works. });
hope this helpful.