其他分享
首页 > 其他分享> > android-GoogleCalendarAPI在API控制台上未注册

android-GoogleCalendarAPI在API控制台上未注册

作者:互联网

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

请检查我下面的代码.

提前致谢.

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之间未发生授权所致.

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

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

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

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(我已经为该应用程序的签名版本创建了一个Client ID,但是如果您还没有这样做,则也需要这样做. ).

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

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

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

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

标签:google-calendar-api,android
来源: https://codeday.me/bug/20191111/2023104.html