質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Firebase Authentication

Firebase Authenticationは、Firebaseを利用したユーザーの認証機能です。バックエンドサービス、SDK、アプリでのユーザー認証に使用できるUIライブラリが用意されています。

Google API

Googleは多種多様なAPIを提供していて、その多くはウェブ開発者向けのAPIです。それらのAPIは消費者に人気なGoogleのサービス(Google Maps, Google Earth, AdSense, Adwords, Google Apps,YouTube等)に基づいています。

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

Q&A

解決済

1回答

2478閲覧

Androidで Cloud Vision APIを呼び出す際の認証方法について

minaoxo

総合スコア0

Firebase Authentication

Firebase Authenticationは、Firebaseを利用したユーザーの認証機能です。バックエンドサービス、SDK、アプリでのユーザー認証に使用できるUIライブラリが用意されています。

Google API

Googleは多種多様なAPIを提供していて、その多くはウェブ開発者向けのAPIです。それらのAPIは消費者に人気なGoogleのサービス(Google Maps, Google Earth, AdSense, Adwords, Google Apps,YouTube等)に基づいています。

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

0グッド

0クリップ

投稿2021/07/04 06:11

編集2021/07/05 11:30

##【実施内容】
JavaでAndroidアプリ作成しています。
その中でCloud Vision APIを使用したい。

##【問題】
android studioでは、下記のエラーがで発生します。

err:com.google.firebase.functions.FirebaseFunctionsException: annotateImage must be called while authenticated.

firebaseのFunctionsでは、下記のエラーが発生します。

8:12:51.936 午後 annotateImage Function execution started 8:12:51.944 午後 annotateImage Callable request verification passed 8:12:51.945 午後 annotateImage Function execution took 61 ms, finished with status code: 401

認証処理が必要かと思い下記をコピーして認証処理を作成しましたがエラーが発生します。
参考:https://firebase.google.cn/docs/auth/android/google-signin?hl=ja
https://github.com/jirawatee/FirebaseAuth-Android/blob/master/app/src/main/java/com/example/auth/GoogleSignInActivity.java

「R.string.default_web_client_id」はOAuth 2.0 クライアント IDのandroid用のものに直接文字列を記載しています。

W/GoogleActivity: Google sign in failed com.google.android.gms.common.api.ApiException: 10: at com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus(com.google.android.gms:play-services-base@@17.6.0:3) at com.google.android.gms.auth.api.signin.GoogleSignIn.getSignedInAccountFromIntent(com.google.android.gms:play-services-auth@@19.0.0:9) at com.app.myfavoritelibrary.activity.GoogleSignInActivity.onActivityResult(GoogleSignInActivity.java:77) at android.app.Activity.dispatchActivityResult(Activity.java:8310) at android.app.ActivityThread.deliverResults(ActivityThread.java:5008) at android.app.ActivityThread.handleSendResult(ActivityThread.java:5056) at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7656) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) V/FA: Activity resumed, time: 133647942 V/FA: Inactivity, disconnecting from the service

##【質問】
・cloud viewを使用するためにGoogleからログインの認証をしたいのですが「Google sign in failed」を解決する方法があれば知りたいです。
・401エラーを解消する方法を知っていましたらご教授いただきたいです。
お手数をおかけしますがよろしくお願いいたします。

##【参考】
https://firebase.google.com/docs/ml/android/recognize-text?hl=ja
・versionなど適当なのですがapp gradleは下記です。

plugins { id 'com.android.application' id 'com.google.gms.google-services' } android { compileSdkVersion 30 buildToolsVersion '30.0.2' defaultConfig { applicationId "com.app.myfavoritelibrary" minSdkVersion 30 targetSdkVersion 30 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { // Import the Firebase BoM implementation platform('com.google.firebase:firebase-bom:28.2.0') implementation 'com.google.firebase:firebase-analytics' implementation 'com.google.firebase:firebase-installations:17.0.0' implementation 'com.google.firebase:firebase-ml-vision-barcode-model:16.0.2' implementation 'com.google.android.gms:play-services-mlkit-text-recognition:16.3.0' implementation 'com.google.firebase:firebase-functions:20.0.0' // 認証 implementation 'com.google.firebase:firebase-auth' implementation 'com.google.android.gms:play-services-auth:19.0.0' implementation 'com.google.code.gson:gson:2.8.7' // レイアウト implementation 'androidx.gridlayout:gridlayout:1.0.0' // openCV implementation project(path: ':opencv-sdk') implementation 'androidx.appcompat:appcompat:1.4.0-alpha02' // camera def camerax_version = '1.1.0-alpha06' implementation "androidx.camera:camera-lifecycle:${camerax_version}" implementation 'androidx.camera:camera-extensions:1.0.0-alpha26' implementation "androidx.camera:camera-camera2:$camerax_version" implementation "androidx.camera:camera-lifecycle:$camerax_version" implementation 'androidx.camera:camera-view:1.0.0-alpha26' implementation "androidx.camera:camera-core:${camerax_version}" implementation 'androidx.appcompat:appcompat:1.4.0-alpha02' implementation 'com.google.android.material:material:1.3.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation project(path: ':opencv-sdk') testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' }

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

下記の行を修正しないで実行したところ正常に動作しました。

.requestIdToken(getString(R.string.default_web_client_id))

投稿2021/07/05 22:56

minaoxo

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問