2

我正在尝试为 vk.com 授权配置satellizer。但是,在尝试进行身份验证时,我不断收到 500 内部服务器错误。这是我的配置:

在客户端:

$authProvider.oauth2({
    name: 'vkontakte',
    url: '/auth/vk',
    redirectUri:window.location.origin || window.location.protocol + '//' + window.location.host,
    clientId: 'my-client-id',
    authorizationEndpoint: 'http://oauth.vk.com/authorize',
    scope: 'friends, photos, email, photo_big',
    display: 'popup',
    responseType: 'code',
    requiredUrlParams: ['response_type', 'client_id', 'redirect_uri', 'display', 'scope', 'v'],
    scopeDelimiter: ',',
    v: '5.37'
});

以及服务器端路由的相关部分:

//vkontakte
app.post('/auth/vk', function(req, res) {
    var accessTokenUrl = 'https://oauth.vk.com/access_token';
    var params = {
        code: req.body.code,
        client_id: req.body.clientId,
        client_secret: config.auth.facebook.clientSecret,
        redirect_uri: req.body.redirectUri
    };

    request.get({ url: accessTokenUrl, qs: params, json: true }, function(err, response, accessToken) {
        if (response.statusCode !== 200) {
            return res.status(500).send({ message: accessToken.error.message });
        }
        var graphApiUrl = 'https://api.vk.com/method/users.get?user_id=' + accessToken.user_id +'&access_token=' + accessToken;

        request.get({ url: graphApiUrl, qs: accessToken, json: true }, function(err, response, profile) {
           ...
        });
    });
});

看起来我做错了什么。Facebook 授权工作正常,因此问题很可能与配置有关。有没有人有任何想法?

4

0 回答 0