I'm trying to create a backend and JavaScript client using Google Cloud Endpoints. User authorization works fine through API explorer and on backend 'user' object is populated. However when similar call is made from JavaScript client, 'user' is null on backend. On client side user is authorized and access token is also valid.
我正在尝试使用Google Cloud Endpoints创建后端和JavaScript客户端。用户授权通过API资源管理器正常工作,并在后端“用户”对象上填充。但是,当从JavaScript客户端进行类似调用时,后端的“user”为null。在客户端,用户被授权,访问令牌也有效。
Please let me know if there is any known issue from Google App Engine or any fix available.
如果Google App Engine中存在任何已知问题或任何可用的修复程序,请与我们联系。
1 个解决方案
#1
1
Check that the scopes you request with the Javascript Client Library
reflect the scopes that you require in your Cloud Enpoints API
.
检查您使用Javascript客户端库请求的范围是否反映了您在Cloud Enpoints API中所需的范围。
index.js
index.js
gapi.auth.authorize({
client_id: 'YOUR_CLIENT_ID',
scope: 'https://www.googleapis.com/auth/userinfo.email',
immediate: true //This is optional
}, callback);
Endpoint.java
Endpoint.java
@Api(
name = "ENDPOINT_NAME",
clientIds = {
com.google.api.server.spi.Constant.API_EXPLORER_CLIENT_ID,
'YOUR_CLIENT_ID'
}
scopes = {"https://www.googleapis.com/auth/userinfo.email"},
)
#1
1
Check that the scopes you request with the Javascript Client Library
reflect the scopes that you require in your Cloud Enpoints API
.
检查您使用Javascript客户端库请求的范围是否反映了您在Cloud Enpoints API中所需的范围。
index.js
index.js
gapi.auth.authorize({
client_id: 'YOUR_CLIENT_ID',
scope: 'https://www.googleapis.com/auth/userinfo.email',
immediate: true //This is optional
}, callback);
Endpoint.java
Endpoint.java
@Api(
name = "ENDPOINT_NAME",
clientIds = {
com.google.api.server.spi.Constant.API_EXPLORER_CLIENT_ID,
'YOUR_CLIENT_ID'
}
scopes = {"https://www.googleapis.com/auth/userinfo.email"},
)