Re: gapi.auth.authorize not working?

442 views
Skip to first unread message

Jaffar Hussain

unread,
Jan 5, 2014, 9:58:47 AM1/5/14
to google-api-jav...@googlegroups.com
hi,

try to use on localhost or somewhere on host.


do not try to load file directly, i think this is your problem.




On Thursday, January 2, 2014 12:40:15 AM UTC+5, Aakash Indurkhya wrote:
So I've been looking through old posts to try and debug my problem with gapi.auth.authorize... To be honest I'm new to this stuff so any help would be appreciated. My problem is that auth.init isn't working. As a result, checkAuth is never getting called. I'm also getting another error that I can't really make sense of: 

  1. Unable to post message to file://. Recipient has origin null. core:rpc:shindig.random:shindig.sha1.js?c=2:838



      var clientId = '591751286145.apps.googleusercontent.com';

      var apiKey = 'AIzaSyB0mteDV5vDKFR-iAv4Fx4OC2gp1Yhqe9U';


      function handleClientLoad() {
        console.log('API key provided - authorizing client...');
        // Step 2: Reference the API key
        gapi.client.setApiKey(apiKey);
        gapi.auth.init(checkAuth);
      }

      function checkAuth() {
        console.log('entered checkAuth - authorizing...');
        setTimeout(function() { 
            console.log("requesting auth");
            gapi.auth.authorize({ 
                client_id: clientId, 
                scope: scopes, 
                response_type:'token',
                immediate: true 
            }, handleAuthResult); 
        }, 100); 
      }

      function handleAuthResult(authResult) {
        console.log('received authResult');
        var authorizeButton = document.getElementById('authorize-button');
        if (authResult && !authResult.error) {
          console.log("auth. successful");
          authorizeButton.style.visibility = 'hidden';
          makeApiCall();
        } else {
          console.log('auth failed.');
          authorizeButton.style.visibility = '';
          authorizeButton.onclick = handleAuthClick;
        }
      }
Reply all
Reply to author
Forward
Message has been deleted
0 new messages