Trying to use Amplify withAuthenticator, throwing error? - javascript

I am trying to sign in on AWS amplify using the withAuthenticator. I am able to make an account but as soon as I try to log in with the correct credentials I always encounter this error.
I am running the app on Expo ios device and the user is saved in cognito. It won't let me sign in and I keep getting this error though.
[ERROR] 49:25.730 AuthClass - Failed to get the signed in user, [Error: Failed to create storage directory.Error Domain=NSCocoaErrorDomain Code=512 "The file “ExponentExperienceData” couldn’t be saved in the folder “Documents”." UserInfo={NSFilePath=/Users/****/Library/Developer/CoreSimulator/Devices/A8619F07-3B7B-47DE-BD92-21B3E8FAB9CE/data/Containers/Data/Application/7CAFFBF4-B523-4E2F-B108-94B0940675C1/Documents/ExponentExperienceData, NSUnderlyingError=0x600002749dd0 {Error Domain=NSPOSIXErrorDomain Code=20 "Not a directory"}}]
at node_modules/#aws-amplify/core/lib-esm/Logger/ConsoleLogger.js:99:15 in prototype._log
at node_modules/#aws-amplify/core/lib-esm/Logger/ConsoleLogger.js:170:23 in prototype.error
at node_modules/#aws-amplify/auth/lib-esm/Auth.js:520:40 in __generator$argument_1
at node_modules/#aws-amplify/auth/node_modules/tslib/tslib.js:141:30 in step
at node_modules/#aws-amplify/auth/node_modules/tslib/tslib.js:122:60 in <anonymous>
at node_modules/#aws-amplify/auth/node_modules/tslib/tslib.js:113:68 in rejected
I have tried creating new accounts as well as trying to use another device. I get the same error.

Related

React native fetch() causing unknown error Error: ENOENT: no such file or directory, open 'C:\root\react-native\ReactAndroid\hermes-engine.cxx\Release

I have made a simple REST API, and I have a react native application where I am trying to call the API with fetch. The server is running on the same computer as the react native application, in my fetch call I used 'fetch('http://10.0.2.2:3000/Users)' which from what I know is the correct way to call it. When I run my react-native application to test if the connection works, I get the following error:
Error: ENOENT: no such file or directory, open 'C:\root\react-native\ReactAndroid\hermes-engine.cxx\Release\21w5t5f5\x86_64\lib\InternalBytecode\InternalBytecode.js'
at Object.openSync (node:fs:584:3)
at Object.readFileSync (node:fs:452:35)
at getCodeFrame (C:\Users\brayd\projects\startscreentest\node_modules\metro\src\Server.js:1004:18)
at Server._symbolicate (C:\Users\brayd\projects\startscreentest\node_modules\metro\src\Server.js:1073:22)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Server._processRequest (C:\Users\brayd\projects\startscreentest\node_modules\metro\src\Server.js:437:7) {
errno: -4058,
syscall: 'open',
code: 'ENOENT',
path: 'C:\root\react-native\ReactAndroid\hermes-engine.cxx\Release\21w5t5f5\x86_64\lib\InternalBytecode\InternalBytecode.js'
Has anyone got this error before and know of a a solution? Would really appreciate some help with this, I have been tried almost everything I can think of and at this point I am lost as to what I should do.
I have never seen this error before, I have looked online to see if anyone has posted a solution and found nothing, I have no idea how to solve this error, I have been debugging for hours, and have tried countless things including changing the fetch url, making a new application, etc. I know the api works because I have tested all the routes with curl, I know the fetch statements work because I created a js project and tested the fetch statements. For some reason, its just not working on my react-native application, its either giving me the above error, or if I change the url to something else like 'fetch('http://localhost:3000/Users)' it just gives me 'network connection error'.
You have to create a wamp or nginx server on your computer. Then your API project starts on a server. After that, you can access your pc IP address. Actually, your react native simulator doesn't work on your pc. So you can't access the directly pc IP address.

Unit testing with firebase auth emulator requires real service account?

We are using the firebase emulators to write integration tests. One of our functions modifies the claims on a user. As such, our test checks to see if the claim has been added. In our test, we call the following function:
admin.auth().getUser(user.userId)
Our intention is to then check the claims. Unfortunately, when this function is called, we get an error.
(node:96985) UnhandledPromiseRejectionWarning: Error: Credential
implementation provided to initializeApp() via the "credential"
property failed to fetch a valid Google OAuth2 access token with the
following error: "Error fetching access token: Error while making
request: getaddrinfo ENOTFOUND metadata.google.internal. Error code:
ENOTFOUND".
Keep in mind we are running against the local auth emulator, not a cloud service. We found an issue on github which seems to be related: https://github.com/firebase/firebase-tools/issues/1708
Unfortunately, the recommended course of action in that issue is to use an actual service account file from an actual cloud service. We do not check such files into our repos as this would be a security hazard. Does anyone know of a better way to deal with this situation?
In case it is relevant, we also get the following warning:
{"severity":"WARNING","message":"Warning, FIREBASE_CONFIG and
GCLOUD_PROJECT environment variables are missing. Initializing
firebase-admin will fail"}

Access Firestore from Google Functions - Getting metadata from plugin failed with error: Could not refresh access token

I am deploying a google function that does some server computation and writes results in the Firestore DB in the same project.
I follow the how-tos and configure the function by
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
and access the Firestore db by using:
admin.firestore().collection('COLLECTION_NAME').add({data: value});
The IAM user ...#gcf-admin-robot.iam.gserviceaccount.com has the role of the Google Cloud Functions Service Agent assigned.
I get the following error:
Error: 500 undefined: Getting metadata from plugin failed with error: Could not refresh access token: Unsuccessful response status code. Request failed with status code 500
at Object.callErrorFromStatus (/workspace/node_modules/#grpc/grpc-js/build/src/call.js:30:26)
at Object.onReceiveStatus (/workspace/node_modules/#grpc/grpc-js/build/src/client.js:175:52)
at Object.onReceiveStatus (/workspace/node_modules/#grpc/grpc-js/build/src/client-interceptors.js:341:141)
at Object.onReceiveStatus (/workspace/node_modules/#grpc/grpc-js/build/src/client-interceptors.js:304:181)
at Http2CallStream.outputStatus (/workspace/node_modules/#grpc/grpc-js/build/src/call-stream.js:116:74)
at Http2CallStream.maybeOutputStatus (/workspace/node_modules/#grpc/grpc-js/build/src/call-stream.js:155:22)
at Http2CallStream.endCall (/workspace/node_modules/#grpc/grpc-js/build/src/call-stream.js:141:18)
at Http2CallStream.cancelWithStatus (/workspace/node_modules/#grpc/grpc-js/build/src/call-stream.js:457:14)
at callStream.filterStack.sendMetadata.then (/workspace/node_modules/#grpc/grpc-js/build/src/channel.js:225:36)
at process._tickCallback (internal/process/next_tick.js:68:7)
Caused by: Error
at WriteBatch.commit (/workspace/node_modules/#google-cloud/firestore/build/src/write-batch.js:415:23)
at DocumentReference.create (/workspace/node_modules/#google-cloud/firestore/build/src/reference.js:283:14)
at CollectionReference.add (/workspace/node_modules/#google-cloud/firestore/build/src/reference.js:2011:28)
at exports.parseProduct.functions.region.https.onRequest (/workspace/index.js:55:56)
at process._tickCallback (internal/process/next_tick.js:68:7)
code: '500',
details:
'Getting metadata from plugin failed with error: Could not refresh access token: Unsuccessful response status code. Request failed with status
metadata: Metadata { internalRepr: Map {}, options: {} },
note:
'Exception occurred in retry method that was not classified as transient'
What am I doing wrong?
For anyone seeing the above error message. It is connected (at least in this case) to permissions of service accounts.
I was adjusting some permissions and deactivated some accounts that I thought I would not need.
Among them was "projectname"#appspot.gserviceaccount.com
Reactivating it solved my problem.
It would be really good, if Google would show more meaningful error messages in such cases!
It seems to be an internal issue rather than maybe something you're doing. Making a quick search I found a very similar issue in GitHub and SO. From those links, I noticed that it was more about a library and I would suggest to reach Firebase Support since they can check the internals of the environment since it is possible some strange magic could be happening behind the scenes.

XMLHttpRequest error in ReactNative Debug mode

I delete my android emulator and create a new one after this when i build my react native project and active debug mode this error appears on emulator but i dont have any problems with Previous emulator :
Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'http://localhost:8083/create_session'.
and this on browser's console :
Must first create RPC session with a valid host
what should i do?

Error while login into AWS through google in react native

I working on AWS login through google. I'm following this link https://github.com/patw0929/react-native-cognito-login-example but I'm getting problem with AWS. I have added the lib for aws-sdk-react-native-core as in the link But I'm getting error while running the app.
java:45: error: method does not override or implement a method from a supertype
#Override
^
Note: C:\Users\krishna21\Awsslogin\node_modules\aws-sdk-react-native-core\android\src\main\java\com\amazonaws\reactnative\core\BackgroundRunner.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':aws-sdk-react-native-core:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
I have added aws-sdk-react-native-core manually.
John,
1. First of all, the library which you are using is old and try using AWS Amplify instead, which is far superior in features and it been tested for security and errors.
2. In AWS Federated Login can be done in 2 ways, one using Cognito User
Pool as well as using Cognito Identity Pool. I hope you are using
Cognito Identity Pool.
3. Please add the Google Client ID in Edit identity pool->Authentication providers->Google+
4. Whitelist the domain which you are hitting in Google Developer
account.
Full documention is here https://itnext.io/google-sign-in-using-aws-amplify-and-amazon-cognito-69cc3bf219ad
https://aws.amazon.com/blogs/mobile/amplify-framework-adds-authentication-features-and-enhancements-for-ios-and-android-mobile-sdks/

Categories

Resources