StorageException has occurred. User is not authenticated - android

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;
}
}
}

Related

Flutter Firebase AppCheck failure

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.

Proguard issue when trying to login with Firebase UI Auth

I am using Firebase UI Auth to login into the application. The debug build is working fine but when I try to login with the release build the application crashes with an error.
2018-10-02 14:05:23.072 4827-4866/io.palette E/c.b.a.J: Creating atomic field updaters failed
java.lang.RuntimeException: java.security.PrivilegedActionException: java.lang.NoSuchFieldException: No field streamClosed in class Lc/b/a/J$c; (declaration of 'c.b.a.J$c' appears in /data/app/io.palette-1/base.apk)
at java.util.concurrent.atomic.AtomicIntegerFieldUpdater$AtomicIntegerFieldUpdaterImpl.<init>(AtomicIntegerFieldUpdater.java:380)
at java.util.concurrent.atomic.AtomicIntegerFieldUpdater.newUpdater(AtomicIntegerFieldUpdater.java:58)
at c.b.a.J.<clinit>(:77)
at c.b.a.c.c(:420)
at c.b.a.c.a(:395)
at com.google.firebase.firestore.f.zzd.<init>(:102)
at com.google.firebase.firestore.b.zzg.zza(:1217)
at com.google.firebase.firestore.b.zzi.run()
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at com.google.firebase.firestore.g.zza$zza.run(:190)
at java.lang.Thread.run(Thread.java:761)
What could be the possible reason for this?

Error while parsing timestamp in GCM event - Null Android (onMessageReceived not called)

Strange problem occur while getting firebase notification. So whenever my app in background and any firebase notification comes then my onMessageReceived method not called. Logcat showing below error :-
FirebaseMessaging: Error while parsing timestamp in GCM event
java.lang.NumberFormatException: s == null
at java.lang.Integer.parseInt(Integer.java:570)
at java.lang.Integer.parseInt(Integer.java:643)
at com.google.firebase.messaging.zzb.zzc(Unknown Source:81)
at com.google.firebase.messaging.zzb.zze(Unknown Source:2)
at com.google.firebase.messaging.FirebaseMessagingService.zzd(Unknown Source:280)
at com.google.firebase.iid.zzg.run(Unknown Source:26)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source:7)
at java.lang.Thread.run(Thread.java:764)
or
FirebaseMessaging: Error while parsing timestamp in GCM event
java.lang.NumberFormatException: Invalid int: "null"
at java.lang.Integer.invalidInt(Integer.java:138)
at java.lang.Integer.parseInt(Integer.java:358)
at java.lang.Integer.parseInt(Integer.java:334)
at com.google.firebase.messaging.zzb.zzc(Unknown Source)
at com.google.firebase.messaging.zzb.zze(Unknown Source)
at com.google.firebase.messaging.FirebaseMessagingService.zzd(Unknown Source)
at com.google.firebase.iid.zzc.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source)
So now I follow this SO question Android/Firebase - Error while parsing timestamp in GCM event - Null timestamp and change in my server end.
Now server sending timestamp into data object like below :-
{
"data": {
"deeplink": "xyz",
"timestamp": "2018-08-01 20:49:07"
},
"notification": {
"title": "Some random title",
"body": "this is a random body"
}
}
Still my onMessageReceived method not called. I try so many link but not able to resolve my problem. I
https://github.com/flutter/flutter/issues/19004
https://groups.google.com/forum/?hl=es-NI#!topic/firebase-talk/iiDlHDhDpQ8
https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues/784
Make sure you are using latest firebase dependency plugin, because Android 'O'will have atleast com.google.firebase:firebase-messaging:11.2.0 version.. There after follow the basic steps as this_link and set channel id as shown here

FirebaseException: An internal error has occurred. [ Bad Request ]

Calling
final AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
results in
com.google.firebase.FirebaseException: An internal error has occurred. [ Bad Request ]
at com.google.android.gms.internal.zzeaw.zzaw(Unknown Source)
at com.google.android.gms.internal.zzdzu.zza(Unknown Source)
at com.google.android.gms.internal.zzebh.zzax(Unknown Source)
at com.google.android.gms.internal.zzebk.onFailure(Unknown Source)
at com.google.android.gms.internal.zzeay.onTransact(Unknown Source)
at android.os.Binder.execTransact(Binder.java:453)
OAuth 2.0: I do have correct SHA-1 in Google developer console as well as Firebase console.
I do have an up-to-date google-services.json file included in project.

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

Categories

Resources