-
Notifications
You must be signed in to change notification settings - Fork 699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaught TypeError: gapi.auth.getToken() is null #2278
Labels
priority: p3
Desirable enhancement or fix. May not be included in next release.
type: docs
Improvement to the documentation for an API.
type: process
A process-related concern. May include testing, release, or the like.
Comments
ddixit14
added
priority: p3
Desirable enhancement or fix. May not be included in next release.
type: process
A process-related concern. May include testing, release, or the like.
type: docs
Improvement to the documentation for an API.
labels
Mar 20, 2023
Hi @danielsocial12, can you please provide all steps to reproduce this issue? |
Uncaught TypeError: gapi.auth.getToken() is null I have got the issue when we click on Google Sign in. Here's my Script and Library <script src="https://apis.google.com/js/client.js?onload=load"></script> <script> function auth() { var config = { 'client_id':'', 'scope':'https://www.googleapis.com/auth/plus.business.manage', 'access_type':'offline', 'approval_prompt':'force', 'response_type':'code', 'include_granted_scopes':'true', 'prompt':'consent' }; gapi.auth.authorize(config, function() { var code = gapi.auth.getToken().code; //var baseurl = jQuery('.site_baseurl').val(); sendRequest(gapi.auth.getToken().code); if(code) { jQuery.ajax({ url : "/get_google_exchange_token", type: 'POST', data: {'auth_code': code}, success: function(jsonData){ var response = JSON.parse(jsonData); var resp = response.resp; if (resp == 0) { jQuery('.error_message_box').show(); jQuery('.error_message_box .message_box').html(response.message); } else { jQuery("#googleacesstoken").closest('.row').prev('.row').show(); jQuery("#googleacesstoken").closest('.row').show(); jQuery("#googleclientid").closest('.row').show(); jQuery("#googleclientid").closest('.row').next('.button-container').show(); var access_token = response.access_token; var refresh_token = response.refresh_token; var user_id = response.user_id; $("#googleacesstoken").val(access_token); $("#googleclientid").val(user_id); $("#googlerefreshtoken").val(refresh_token); } } }); } }); } function sendRequest(code) { var restRequest = gapi.client.request({ 'path': "https://accounts.google.com/o/oauth2/token", 'method':'POST', 'params': { 'code': code, 'client_id': '', 'client_secret':'', 'rediredt_uri':document.location.origin, 'grant_type':'authorization_code', }, 'headers': { 'Content-type': 'application/json' }, }); restRequest.execute(function(jsonResponse, rawResponse) { rest = jsonResponse; }); } </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
priority: p3
Desirable enhancement or fix. May not be included in next release.
type: docs
Improvement to the documentation for an API.
type: process
A process-related concern. May include testing, release, or the like.
I have got the error message in console:
{"valid":true,"blocked":true,"suppressed":false}
Uncaught TypeError: gapi.auth.getToken() is null.
Authorised JavaScript origins: https://krishan.econference.world/
Authorised redirect URIs: https://krishan.econference.world/social-engagements
Authorised domains: econference.world
Here's my Script:
<script src="https://apis.google.com/js/client.js?onload=load"></script> <script> function auth() { var config = { 'client_id':'', 'scope':'https://www.googleapis.com/auth/plus.business.manage', 'access_type':'offline', 'approval_prompt':'force', 'response_type':'code', 'include_granted_scopes':'true', 'prompt':'consent', 'response_type': 'id_token permission' }; gapi.auth.authorize(config, function() { var code = gapi.auth.getToken().code; //var baseurl = jQuery('.site_baseurl').val(); sendRequest(gapi.auth.getToken().code); if(code) { jQuery.ajax({ url : "/get_google_exchange_token", type: 'POST', data: {'auth_code': code}, success: function(jsonData){ var response = JSON.parse(jsonData); var resp = response.resp; if (resp == 0) { jQuery('.error_message_box').show(); jQuery('.error_message_box .message_box').html(response.message); } else { jQuery("#googleacesstoken").closest('.row').prev('.row').show(); jQuery("#googleacesstoken").closest('.row').show(); jQuery("#googleclientid").closest('.row').show(); jQuery("#googleclientid").closest('.row').next('.button-container').show(); var access_token = response.access_token; var refresh_token = response.refresh_token; var user_id = response.user_id; $("#googleacesstoken").val(access_token); $("#googleclientid").val(user_id); $("#googlerefreshtoken").val(refresh_token); } } }); } }); } function sendRequest(code) { var restRequest = gapi.client.request({ 'path': "https://accounts.google.com/o/oauth2/token", 'method':'POST', 'params': { 'code': code, 'client_id': '', 'client_secret':'', 'rediredt_uri':'document.location.origin', 'grant_type':'authorization_code', }, 'headers': { 'Content-type': 'application/json' }, }); restRequest.execute(function(jsonResponse, rawResponse) { rest = jsonResponse; }); } </script>The text was updated successfully, but these errors were encountered: