0
我试图通过Google云端点从Android应用程序进行认证请求时,在我的Google开发者控制台日志中收到“观众不允许”警告。由于云端点中的“观众不允许”警告导致get_current_user()返回无
通过端点源代码来看,对应于:
aud = parsed_token.get('aud')
cid = parsed_token.get('azp')
if aud != cid and aud not in audiences:
logging.warning('Audience not allowed: %s', aud)
在Android应用我的调用代码:
public static final String WEB_CLIENT_ID = "web-client-id.apps.googleusercontent.com";
public static final String AUDIENCE = "server:client_id:" + WEB_CLIENT_ID;
GoogleAccountCredential credential = GoogleAccountCredential.usingAudience(
mContext,
AUDIENCE
);
Grapi.Builder builder = new Grapi.Builder(HTTP_TRANSPORT,
JSON_FACTORY, credential);
Grapi service = builder.build()
其中“网络客户端ID”是字母数字客户端ID在谷歌开发者控制台中生成。该服务用于进行经认证的呼叫。
这也是被传递给API装饰在我的后端Python代码相同WEB_CLIENT_ID:
WEB_CLIENT_ID = 'web-client-id.apps.googleusercontent.com'
ANDROID_CLIENT_ID = 'android-client-id.apps.googleusercontent.com'
ANDROID_AUDIENCE = WEB_CLIENT_ID
grapi_client_ids = [ANDROID_CLIENT_ID,
WEB_CLIENT_ID,
endpoints.API_EXPLORER_CLIENT_ID]
grapi_audiences = [ANDROID_AUDIENCE]
@endpoints.api(name='grapi', version='v1',
allowed_client_ids=grapi_client_ids, audiences=grapi_audiences,
scopes=[endpoints.EMAIL_SCOPE])
它看起来像所有这一切都是造成endpoints.get_current_user()返回无,我的身份验证呼叫失败。