Google drive api 节点webkit和googledriveapi

Google drive api 节点webkit和googledriveapi,google-drive-api,google-oauth,node-webkit,Google Drive Api,Google Oauth,Node Webkit,试图让Google Drive API在node webkit中工作 发送身份验证消息时,其原始文件为:/,将被拒绝 https://accounts.google.com/o/oauth2/auth ?client_id=<some value> &scope=https://www.googleapis.com/auth/drive.appdata https://www.googleapis.com/auth/drive.file https://www.googlea

试图让Google Drive API在node webkit中工作

发送身份验证消息时,其原始文件为:/,将被拒绝

https://accounts.google.com/o/oauth2/auth
?client_id=<some value>
&scope=https://www.googleapis.com/auth/drive.appdata
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/drive
&immediate=true
&proxy=oauth2relay1232990068
&redirect_uri=postmessage
&origin=file://
&response_type=token
&state=1938150804|0.1319366391
&authuser=0
https://accounts.google.com/o/oauth2/auth
?客户识别码=
&范围=https://www.googleapis.com/auth/drive.appdata
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/drive
&立即=真
&proxy=oauth2relay1232990068
&重定向_uri=postmessage
&来源=文件://
&响应类型=令牌
&州=1938150804 | 0.1319366391
&authuser=0

不知道为什么它是从gapi以这种方式发送的-有人知道如何从node webkit验证google drive吗?

我选择绕过oAuth的API,自己做

用户必须复制一个身份验证代码并将其粘贴到我的应用程序中——这不是第一选择,但他们只需要做一次,这比(缺少)替代方案更好

为感兴趣的人共享代码:

当用户选择Google drive时:

            window.open('https://accounts.google.com/o/oauth2/auth?'
                    + 'client_id=<some value>'
                    + '&scope=<space delimited list of permissions>'
                    + '&redirect_uri=urn:ietf:wg:oauth:2.0:oob'
                    + '&response_type=code');
window.open('https://accounts.google.com/o/oauth2/auth?'
+'客户号='
+“&scope=”
+“&redirect_uri=urn:ietf:wg:oauth:2.0:oob”
+“&response_type=code”);
这将生成一个弹出窗口,让他们允许并显示身份验证代码

当身份验证代码粘贴到我的应用程序中时,我将其保存到DB并继续获取访问代码,然后将其保存到DB:

            $.ajax({
                url: "https://accounts.google.com/o/oauth2/token",
                type: 'post',
                data: {
                    code: <authCode>,
                    client_id: CLIENT_ID,
                    client_secret: CLIENT_SECRET,
                    redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
                    grant_type: 'authorization_code'
                }
            }).error(function(data) {
                myObj.isAuth = false;
                if (cbFail) {
                    cbFail(data);
                }
            }).success(function(data) {
                myObj.isAuth = true;
                <persist entire response>
                if (cbSuccess) {
                    cbSuccess();
                }
            });
$.ajax({
url:“https://accounts.google.com/o/oauth2/token",
键入:“post”,
数据:{
代码:,
客户id:客户id,
客户机密:客户机密,
重定向_uri:'urn:ietf:wg:oauth:2.0:oob',
授权类型:“授权代码”
}
}).错误(函数(数据){
myObj.isAuth=false;
如果(cbFail){
cbFail(数据);
}
}).成功(功能(数据){
myObj.isAuth=true;
如果(cbSuccess){
cbSuccess();
}
});

我猜gapi并不是作为用例使用node编写的。我的简短建议是不要使用它。你知道URL应该是什么样子的,所以直接调用它并解析JSON响应就行了。