我在Google授权中做错了什么?

时间:2014-02-28 00:50:43

标签: javascript html api youtube authorization

我遇到了这个问题:我甚至不知道代码是否正在运行,但在我的网站上,它无法运行。有人知道我做错了吗?

网站:informatica.olvbreda.nl/5hGroepNikki/test.html

HTML

<html>
<head>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2  /jquery.min.js"></script>
<script type="text/javascript" src="//www.google.com/jsapi"></script>
<script type="text/javascript" src="https://apis.google.com/js/client.js?onload=onJSClientLoad"></script>
<script type="text/javascript" src="test.js"></script>
</head>
<body>

<div id="login-container" class="pre-auth"> 
Klik <a href="#" id="login-link">hier</a> om de knop te testen
</div>
<div class="post-auth">
verbonden
</div>
</body>
</html>

的JavaScript

var OAUTH2_CLIENT_ID = '811950662153.apps.googleusercontent.com';
var OAUTH2_SCOPES = ['https://www.googleapis.com/auth/youtube'];


googleApiClientReady = function ()
{
gapi.auth.init(function()
{
    window.setTimeout(checkAuth, 1);
});
}

function checkAuth()
{
gapi.auth.authorize(
{
    client_id: OAUTH2_CLIENT_ID,
    scope: OAUTH2_SCOPES,
    immediate: true
}, handleAuthResult);
}

function handleAuthResult(authResult)
{
if(authResult)
{
    $('.pre-auth').hide();
    $('.post-auth').show();
    loadAPIClientInterfaces();
}
else
    {
        $('#login-link').click(function()
        {
            gapi.auth.authorize(
            {
                client_id: OAUTH2_CLIENT_ID,
                scope: OAUTH2_SCOPES,
                immediate: false
            }, handleAuthResult);
        });
    }
}

function loadAPIClientInterfaces()
{
alert('gelukt');
}

0 个答案:

没有答案