API的OAuth谷歌整合路径错误(原产地不匹配)的谷歌日历 [英] API OAuth Google Integration Access error (origin-mismatch ) for google Calendar

查看:167
本文介绍了API的OAuth谷歌整合路径错误(原产地不匹配)的谷歌日历的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我intgrating谷歌日历与角UI日历,让谷歌日历的事件数据
这是我的HTML

I am intgrating google Calendar with Angular UI Calendar, to get the data of events of google Calendar This is my HTML

<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登录和登录过程顺利进行,但当反应过来,然后错误消息出现在我的网页原产地不匹配。

When I try to acces the data upon click Authorize Button then it goes to google login and login procedure proceed successfully but when response come then Error message comes on my page origin-mismatch .

推荐答案

的问题是解决了。
更换JAVASCRIPT ORIGINS - https://www.example.com与
JAVASCRIPT ORIGINS 的http://本地主机:8080
 如果你有你自己的域名,然后与您的域替换它并具体使用HTTPS或http

The problem is solve . Replace JAVASCRIPT ORIGINS - https://www.example.com with JAVASCRIPT ORIGINS http://localhost:8080 And if you have your own Domain then replace it with your Domain and be specific of using https or http

这篇关于API的OAuth谷歌整合路径错误(原产地不匹配)的谷歌日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆