GoogleCalendarAPI在API控制台上未注册 [英] GoogleCalendarAPI Unregistered on API console

查看:164
本文介绍了GoogleCalendarAPI在API控制台上未注册的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在集成Google日历时,我遇到以下错误.

I have facing below error while integrating Google Calendar.

请检查我下面的代码.

谢谢.

com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAuthIOException
                                                                        at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential$RequestHandler.intercept(GoogleAccountCredential.java:286)
                                                                        at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:859)
                                                                        at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410)
                                                                        at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
                                                                        at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
                                                                        at com.taskdemocal.AsyncLoadTasks.doInBackground(AsyncLoadTasks.java:38)
                                                                        at com.taskdemocal.CommonAsyncTask.doInBackground(CommonAsyncTask.java:55)
                                                                        at com.taskdemocal.CommonAsyncTask.doInBackground(CommonAsyncTask.java:33)
                                                                        at android.os.AsyncTask$2.call(AsyncTask.java:292)
                                                                        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
                                                                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                                                                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                                                                        at java.lang.Thread.run(Thread.java:818)
                                                                     Caused by: com.google.android.gms.auth.GoogleAuthException: UNREGISTERED_ON_API_CONSOLE

推荐答案

该错误很可能是由于您的Android应用程序与Cloud Endpoints API之间未发生授权所致.

The error is most likely due to the authorization not happening between your Android application and the Cloud Endpoints API.

由于我没有完全访问您实际的Endpoint API注释和Android代码的权限,因此建议您仔细查看以下几点:

Since I do not have full access to your actual Endpoint API annotations and the Android code, I would suggest that you look at the following points closely:

确保已使用clientIds和受众正确注释了Cloud Endpoints API. Android Audience值与Web客户端ID相同. 确保已部署更新的API并重新生成了Endpoints API源,以将其包含在Android应用程序中. 最后,在您的Android源代码中,您必须使用GoogleAccountCredential.usingAudience(...)构建GoogleAccountCredential的实例,然后在调用端点API时使用此凭据对象.例如端点构建器将使用HTTP传输,GSON工厂和凭据.不要将最后一个参数(即凭据)留空.

Ensure that you have annotated your Cloud Endpoints API correctly with the clientIds and audiences. The Android Audience value is the same as that of the Web Client Id. Make sure you have deployed the updated API and regenerated the Endpoints API sources for inclusion in your Android application. Finally, in your Androids source code, you must build an instance of the GoogleAccountCredential, using the GoogleAccountCredential.usingAudience(...) and then use this credential object while making a call to the endpoint API. For e.g. the Endpoint builder takes a HTTP Transport, GSON Factory and the Credential. Do not leave the last parameter (i.e. Credential) as empty.

我也收到了类似的GoogleAuthIOException异常:

I was also getting a similar GoogleAuthIOException exception:

com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAuthIOException
at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential$RequestHandler.intercept(GoogleAccountCredential.java:286)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:859)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
at com.example.MainActivity$ListPartiesTask.doInBackground(MainActivity.java:188)
at com.example.MainActivity$ListPartiesTask.doInBackground(MainActivity.java:178)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:841)
Caused by: com.google.android.gms.auth.GoogleAuthException: Unknown
at com.google.android.gms.auth.GoogleAuthUtil.zzb(Unknown Source)
at com.google.android.gms.auth.GoogleAuthUtil.zza(Unknown Source)
at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential.getToken(GoogleAccountCredential.java:255)
at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential$RequestHandler.intercept(GoogleAccountCredential.java:279)
... 12 more

结果是,我需要使用该应用程序的调试版本的sha1指纹创建一个Client ID(我已经为该应用程序的签名版本创建了一个ID,但是如果您尚未这样做,则需要也这样做).

Turns out I needed to create a Client ID with the sha1 fingerprint of the debug version of the app (I had already created one for the signed version of the app, but if you haven't done that you'll need to do that too).

您可以使用以下命令获取指纹(在Mac上,debug.keystore的地址在其他系统上可能会有所不同)

You can get the fingerprint with the following command (on a Mac, address of debug.keystore might be different on other systems):

 keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

如果您需要获取释放密钥的指纹,则可以执行以下操作:

If you need to get the fingerprint for your release key you can do this:

keytool -list -v -keystore /PATH/TO/YOUR/release-key.jks -alias RELEASE_KEY_ALIAS

这篇关于GoogleCalendarAPI在API控制台上未注册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆