Flutter Firebase AppCheck failure - android

E/flutter (28083): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: [firebase_storage/unauthenticated] User is unauthenticated. Authenticate and try again.
E/flutter (28083): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: [firebase_storage/unauthenticated] User is unauthenticated. Authenticate and try again.
E/StorageException(28083): { "error": { "code": 401, "message": "Firebase App Check token is invalid." }}
E/StorageException(28083): java.io.IOException: { "error": { "code": 401, "message": "Firebase App Check token is invalid." }}
I get this errors when i try to get images from Firebase Storage.

Related

StorageException has occurred. User is not authenticated

The error is risen when I try to upload to the storage. I've already implemented authentication in my app, and am having no problem with creating a user and authenticating. StorageException has occurred.
User is not authenticated, please authenticate using Firebase Authentication and try again. Error -13020 HttpResult: 401
2022-04-28 17:26:45.646 30490-30886/com.apps.myshop E/StorageException: The server has terminated the upload session java.io.IOException: The server has terminated the upload session
I use next rules
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write;
}
}
}
There are examples of my log errors
StorageException has occurred.
User is not authenticated, please authenticate using Firebase Authentication and try again.
Code: -13020 HttpResult: 401
2022-04-28 17:26:45.646 30490-30886/com.apps.myshop E/StorageException: The server has terminated the upload session
java.io.IOException: The server has terminated the upload session
at com.google.firebase.storage.UploadTask.serverStateValid(UploadTask.java:339)
at com.google.firebase.storage.UploadTask.shouldContinue(UploadTask.java:308)
at com.google.firebase.storage.UploadTask.run(UploadTask.java:229)
at com.google.firebase.storage.StorageTask.lambda$getRunnable$7$com-google-firebase-storage-StorageTask(StorageTask.java:1072)
at com.google.firebase.storage.StorageTask$$ExternalSyntheticLambda3.run(Unknown Source:2)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
Caused by: java.io.IOException: { "error": { "code": 401, "message": "Firebase App Check token is invalid." }}
at com.google.firebase.storage.network.NetworkRequest.parseResponse(NetworkRequest.java:445)
at com.google.firebase.storage.network.NetworkRequest.parseErrorResponse(NetworkRequest.java:462)
at com.google.firebase.storage.network.NetworkRequest.processResponseStream(NetworkRequest.java:453)
at com.google.firebase.storage.network.NetworkRequest.performRequest(NetworkRequest.java:272)
at com.google.firebase.storage.network.NetworkRequest.performRequest(NetworkRequest.java:289)
at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(ExponentialBackoffSender.java:76)
at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(ExponentialBackoffSender.java:68)
at com.google.firebase.storage.UploadTask.sendWithRetry(UploadTask.java:477)
at com.google.firebase.storage.UploadTask.beginResumableUpload(UploadTask.java:276)
at com.google.firebase.storage.UploadTask.run(UploadTask.java:224)
at com.google.firebase.storage.StorageTask.lambda$getRunnable$7$com-google-firebase-storage-StorageTask(StorageTask.java:1072) 
at com.google.firebase.storage.StorageTask$$ExternalSyntheticLambda3.run(Unknown Source:2) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
at java.lang.Thread.run(Thread.java:923) 
2022-04-28 17:26:45.646 30490-30886/com.apps.myshop E/StorageException: StorageException has occurred.
User is not authenticated, please authenticate using Firebase Authentication and try again.
Code: -13020 HttpResult: 401
2022-04-28 17:26:45.647 30490-30886/com.apps.myshop E/StorageException: The server has terminated the upload session
java.io.IOException: The server has terminated the upload session
at com.google.firebase.storage.UploadTask.serverStateValid(UploadTask.java:339)
at com.google.firebase.storage.UploadTask.shouldContinue(UploadTask.java:308)
at com.google.firebase.storage.UploadTask.run(UploadTask.java:229)
at com.google.firebase.storage.StorageTask.lambda$getRunnable$7$com-google-firebase-storage-StorageTask(StorageTask.java:1072)
at com.google.firebase.storage.StorageTask$$ExternalSyntheticLambda3.run(Unknown Source:2)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
Caused by: java.io.IOException: { "error": { "code": 401, "message": "Firebase App Check token is invalid." }}
at com.google.firebase.storage.network.NetworkRequest.parseResponse(NetworkRequest.java:445)
at com.google.firebase.storage.network.NetworkRequest.parseErrorResponse(NetworkRequest.java:462)
at com.google.firebase.storage.network.NetworkRequest.processResponseStream(NetworkRequest.java:453)
at com.google.firebase.storage.network.NetworkRequest.performRequest(NetworkRequest.java:272)
at com.google.firebase.storage.network.NetworkRequest.performRequest(NetworkRequest.java:289)
at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(ExponentialBackoffSender.java:76)
at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(ExponentialBackoffSender.java:68)
at com.google.firebase.storage.UploadTask.sendWithRetry(UploadTask.java:477)
at com.google.firebase.storage.UploadTask.beginResumableUpload(UploadTask.java:276)
at com.google.firebase.storage.UploadTask.run(UploadTask.java:224)
at com.google.firebase.storage.StorageTask.lambda$getRunnable$7$com-google-firebase-storage-StorageTask(StorageTask.java:1072) 
at com.google.firebase.storage.StorageTask$$ExternalSyntheticLambda3.run(Unknown Source:2) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
at java.lang.Thread.run(Thread.java:923) 
2022-04-28 17:26:45.655 30490-30490/com.apps.myshop E/Error while uploading: Error while uploading image to db
com.google.firebase.storage.StorageException: User is not authenticated, please authenticate using Firebase Authentication and try again.
at com.google.firebase.storage.UploadTask.snapStateImpl(UploadTask.java:524)
at com.google.firebase.storage.UploadTask.snapStateImpl(UploadTask.java:50)
at com.google.firebase.storage.StorageTask.snapState(StorageTask.java:343)
at com.google.firebase.storage.TaskListenerImpl.onInternalStateChanged(TaskListenerImpl.java:85)
at com.google.firebase.storage.StorageTask.tryChangeState(StorageTask.java:390)
at com.google.firebase.storage.StorageTask.tryChangeState(StorageTask.java:426)
at com.google.firebase.storage.UploadTask.serverStateValid(UploadTask.java:342)
at com.google.firebase.storage.UploadTask.shouldContinue(UploadTask.java:308)
at com.google.firebase.storage.UploadTask.run(UploadTask.java:229)
at com.google.firebase.storage.StorageTask.lambda$getRunnable$7$com-google-firebase-storage-StorageTask(StorageTask.java:1072)
at com.google.firebase.storage.StorageTask$$ExternalSyntheticLambda3.run(Unknown Source:2)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
Caused by: java.io.IOException: The server has terminated the upload session
at com.google.firebase.storage.UploadTask.serverStateValid(UploadTask.java:339)
at com.google.firebase.storage.UploadTask.shouldContinue(UploadTask.java:308) 
at com.google.firebase.storage.UploadTask.run(UploadTask.java:229) 
at com.google.firebase.storage.StorageTask.lambda$getRunnable$7$com-google-firebase-storage-StorageTask(StorageTask.java:1072) 
at com.google.firebase.storage.StorageTask$$ExternalSyntheticLambda3.run(Unknown Source:2) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
at java.lang.Thread.run(Thread.java:923) 
Caused by: java.io.IOException: { "error": { "code": 401, "message": "Firebase App Check token is invalid." }}
at com.google.firebase.storage.network.NetworkRequest.parseResponse(NetworkRequest.java:445)
at com.google.firebase.storage.network.NetworkRequest.parseErrorResponse(NetworkRequest.java:462)
at com.google.firebase.storage.network.NetworkRequest.processResponseStream(NetworkRequest.java:453)
at com.google.firebase.storage.network.NetworkRequest.performRequest(NetworkRequest.java:272)
at com.google.firebase.storage.network.NetworkRequest.performRequest(NetworkRequest.java:289)
at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(ExponentialBackoffSender.java:76)
at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(ExponentialBackoffSender.java:68)
at com.google.firebase.storage.UploadTask.sendWithRetry(UploadTask.java:477)
at com.google.firebase.storage.UploadTask.beginResumableUpload(UploadTask.java:276)
at com.google.firebase.storage.UploadTask.run(UploadTask.java:224)
Try adding create, although I suspect create should be included with write.
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write, update, delete, create;
}
}
}

FirebaseUI Android: Error fetching providers for email (Backend Error)

We use Firebase and FirebaseUI-Auth with email accounts in one of our Android apps.
When we try to log in using FirebaseUI-Auth with a specific email account, the progress dialog (progress_dialog_checking_accounts) hides without showing an error and what we see in logcat is the following:
W/CheckEmailFragment: Error fetching providers for email
com.google.firebase.c: An internal error has occurred. [ Backend Error ]
at com.google.android.gms.c.eg.a(Unknown Source)
at com.google.android.gms.c.ed$f.a(Unknown Source)
at com.google.android.gms.c.eo.a(Unknown Source)
at com.google.android.gms.c.eo$a.a(Unknown Source)
at com.google.android.gms.c.ej$a.onTransact(Unknown Source)
at android.os.Binder.execTransact(Binder.java:453)
The results of the following curl request are not very informative either:
curl 'https://www.googleapis.com/identitytoolkit/v3/relyingparty/createAuthUri?key=${MyFirebaseAPIKey}' -H 'Content-Type: application/json' --data-binary '{"identifier": "${ProblematicEmailAddress}","continueUri":"http://localhost"}'
{
"error": {
"errors": [
{
"domain": "global",
"reason": "backendError",
"message": "Backend Error"
}
],
"code": 500,
"message": "Backend Error"
}
}
I get a good response with another email address (also a registered account):
{
"kind": "identitytoolkit#CreateAuthUriResponse",
"allProviders": [
"password"
],
"registered": true,
"sessionId": "${replaced}"
}
Does anyone know what is happening and how we can solve this error? We are concerned, that this might occur for other email accounts as well, thus preventing users from signing in.

Youtube WatchMe android project Login issue

I created live streaming application using https://github.com/youtube/yt-watchme. And its installed on android phone.If I logged into this app.I's still shows the "Not Signed in" Message. After login its showing the following error in android studio console
09-16 16:48:01.970 25937-3107/com.google.android.apps.watchme E/WatchMe﹕ com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code": 403,
"errors": [
{
"domain": "usageLimits",
"message": "Access Not Configured. The API (YouTube Data API) is not enabled for your project. Please use the Google Developers Console to update your configuration.",
"reason": "accessNotConfigured",
"extendedHelp": "https://console.developers.google.com"
}
],
"message": "Access Not Configured. The API (YouTube Data API) is not enabled for your project. Please use the Google Developers Console to update your configuration."
}
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:321)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1056)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
at com.google.android.apps.watchme.util.YouTubeApi.getLiveEvents(YouTubeApi.java:155)
at com.google.android.apps.watchme.MainActivity$GetLiveEventsTask.doInBackground(MainActivity.java:312)
at com.google.android.apps.watchme.MainActivity$GetLiveEventsTask.doInBackground(MainActivity.java:295)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
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:841)
How can i solve this issue please help.
This application is connecting to YouTube Watch Me project.Is it possible to connect my project using client Id and client secret(How can i configure my client id to this app?)?
Please suggest

403 Forbidden Error when doing Android Google Calendar Quickstart

I'm trying to add Google Calendar integration with my app. I followed the Android quickstart guide here https://developers.google.com/google-apps/calendar/quickstart/android
I was having problems integrating this into my existing project, so I tried making a fresh project and copy and pasting the code. However, I'm still getting this error:
403 Forbidden
{
"code": 403,
"errors": [
{
"domain": "usageLimits",
"message": "Access Not Configured. The API (Calendar API) is not enabled for your project. Please use the Google Developers Console to update your configuration.",
"reason": "accessNotConfigured",
"extendedHelp": "https://console.developers.google.com"
}
],
"message": "Access Not Configured. The API (Calendar API) is not enabled for your project. Please use the Google Developers Console to update your configuration."
}
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:321)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1056)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
at com.gdosheriii.android.calendartest.ApiAsyncTask.getDataFromApi(ApiAsyncTask.java:72)
at com.gdosheriii.android.calendartest.ApiAsyncTask.doInBackground(ApiAsyncTask.java:39)
at com.gdosheriii.android.calendartest.ApiAsyncTask.doInBackground(ApiAsyncTask.java:19)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
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:841)
What am I doing wrong? I've been googling for an answer for the past two hours, but nothing seems to fix it. Yes, I did create a client id inside the Google Developers Console. I copied and pasted the package (com.gdosheriii.android.calendartest) and the SHA1 key. I have the Calendar API enabled.
What is the correct way to do it?
Thanks for the help!
you need to change application name in code de google quistart, you can do that by following this next steps:
private class MakeRequestTask extends AsyncTask<Void, Void, List<String>> {
private com.google.api.services.calendar.Calendar mService = null;
private Exception mLastError = null;
public MakeRequestTask(GoogleAccountCredential credential) {
HttpTransport transport = AndroidHttp.newCompatibleTransport();
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
mService = new com.google.api.services.calendar.Calendar.Builder(
transport, jsonFactory, credential)
.setApplicationName("YOUR APPLICATION NAME IN GOOGLE CONSOLE")
.build();
}

AndroidAnnotations restClient get responsebody of 404 error

I am doing an API call but the API sends back an error with the status code 404. How can I get the response of the API so I can see what the exact error is?
The error I am getting is:
08-12 09:52:05.977 11040-11221/eu.app W/RestTemplate﹕ POST request for "http://hidden-api-url.com" resulted in 404 (Not Found); invoking error handler
08-12 09:52:09.051 11040-11221/eu.app E/AndroidRuntime﹕ FATAL EXCEPTION: pool-5-thread-3
Process: eu.app, PID: 11040
org.springframework.web.client.HttpClientErrorException: 404 Not Found
I found the solution. I caught the HttpClientErrorException and got the response with getResponseBodyAsString();.
try {
restClient.restCall(data);
} catch (HttpClientErrorException e) {
Log.d("Response",e.getResponseBodyAsString());
}

Categories

Resources