问题描述
新手试图弄清楚如何让Node.js应用程序对Google BigQuery进行身份验证和查询,试图修改。
首先我使用我的客户创建这个Oauth2 URL:
https://accounts.google.com/o/oauth2/auth?
client_id = 1047877053699-den6kbs4v3f2bft6clonsirkj1pc7t6j.apps.googleusercontent.com
& scope = https://www.googleapis.com/auth/bigquery
& redirect_uri = http:// localhost: 3000 / oauth2callback
& access_type = offline
& response_type = code
这成功地到达了谷歌,它提示
同意生成第二个提示:
同意,回调网址为名为 accessToken
。
我认为下面的url应该列出表格在我的BigQuery项目/数据集中:
但是,使用或不使用accessToken的调用会返回以下消息:需要登录。
{
error:{
errors:[
{
domain:global ,
reason:required,
message:需要登录,
locationType:header,$ b $location:Authorization
code:401,
message:需要登录
}
}
我知道你不能重复代码,因为权限,过期令牌等。但是我想知道我可能在概念上缺少什么步骤。
您是否尝试过se将accesstoken作为授权头文件而不是url参数?
与
https://www.googleapis.com/bigquery/v2/projects/1047877053699/datasets/visits
授权:OAuth Your-access-token-here-not-urlencoded
code>
Newbie trying to figure out how to get a Node.js application to authenticate and query Google BigQuery, trying to adapt this CodeLab tutorial from Java. What step might i be missing?
First I create this Oauth2 URL using my clientid:
https://accounts.google.com/o/oauth2/auth?
client_id=1047877053699-den6kbs4v3f2bft6clonsirkj1pc7t6j.apps.googleusercontent.com
&scope=https://www.googleapis.com/auth/bigquery
&redirect_uri=http://localhost:3000/oauth2callback
&access_type=offline
&response_type=code
This successfully reaches Google, which prompts
Agreeing that generates a second prompt:
Agreeing to that, the callback URL is called, with a parameter accessToken
.
I think the following url should list tables in my BigQuery project/dataset:
But calling with or without the accessToken returns the following message that "Login Required".
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
I know you can't repeat the code because of permissions, expired tokens, etc. But I wonder what step I might be missing conceptually.
Have you tried sending the accesstoken as an authorization header rather than as a url parameter?
as in
https://www.googleapis.com/bigquery/v2/projects/1047877053699/datasets/visits
Authorization: OAuth Your-access-token-here-not-urlencoded
这篇关于通过Node.js中的OAuth2对BigQuery REST API进行身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!