2014-12-28 40 views
2

我intgrating谷歌日曆與角UI日曆,讓谷歌日曆 的事件的數據。這是我的HTMLAPI的OAuth谷歌整合路徑錯誤(產地不匹配)的谷歌日曆

<div ng-controller="newCalendarCtrl"> 
<button ng-click="handleAuthClick()">Authorize</button> 
<script src="https://apis.google.com/js/client.js"></script> 
</div> 

這是我的JS

angular.module('loginApp').controller('newCalendarCtrl', function ($scope, $log) { 

    var clientId = '*******' 
    //var apiKey = '{API KEY}'; 
    var scopes = 'https://www.googleapis.com/auth/calendar'; 

    function handleAuthResult(authResult) { 
     console.log(authResult); 
     var authorizeButton = document.getElementById('authorize-button'); 
     if (authResult && !authResult.error) { 
      // authorizeButton.style.visibility = 'hidden'; 
      makeApiCall(); 
     } else { 
      authorizeButton.style.visibility = ''; 
      authorizeButton.onclick = handleAuthClick; 
     } 
    } 

    $scope.handleAuthClick=function (event) { 
     gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: false}, handleAuthResult); 
     return false; 
    } 

    function makeApiCall() { 
     gapi.client.load('calendar', 'v3', function() { 
      var request = gapi.client.calendar.calendarList.list(); 
      request.execute(function(resp){ 
       $.each(resp.items, function(key, value) { 
        console.log(resp.items[key].id); 
       }); 
      }); 
      var request1 = gapi.client.calendar.events.list({ 
       'calendarId': 'primary', 
       'timeMin': '2015-12-23T04:26:52.000Z'//Suppose that you want get data after 23 Dec 2014 
      }); 
      request1.execute(function(resp){ 
       $.each(resp.items, function(key, value) { 
        console.log(resp.items[key].id); 
       }); 
      }); 
     }); 
    } 

}); 

當我嘗試存取權限後點擊授權按鈕,然後它去Google登錄和登錄過程順利進行的數據,但是當反應過來,然後錯誤消息出現在我的網頁起源不匹配。

回答

2

問題解決了。 更換JAVASCRIPT ORIGINS - https://www.example.com與 JAVASCRIPT ORIGINS http://localhost:8080 如果你有你自己的域名,然後與您的域名替換它並具體使用HTTPS或HTTP