eas-cli icon indicating copy to clipboard operation
eas-cli copied to clipboard

AWS Amplify requires amazon-cognito-identity-js in managed EAS Build

Open timhbt opened this issue 5 years ago • 10 comments

Summary

When using Auth.signIn(), no requests go out and it loads infinitely. Backend url is secure (https).

The same code works with classic build (expo build) and expo publish.

Environment

EAS CLI 0.35.0 environment info: System: OS: Linux 5.4 Ubuntu 20.04.3 LTS (Focal Fossa) Shell: 5.0.17 - /bin/bash Binaries: Node: 14.18.1 - /usr/bin/node Yarn: 1.22.15 - /usr/bin/yarn npm: 6.14.15 - /usr/bin/npm Utilities: Git: 2.25.1 - /usr/bin/git npmPackages: expo: ^43.0.2 => 43.0.2 expo-cli: 4.13.0 => 4.13.0 react: 17.0.1 => 17.0.1 react-dom: 17.0.1 => 17.0.1 react-native: 0.64.3 => 0.64.3 react-native-web: 0.17.1 => 0.17.1

Error output

Error in adb logcat grafik

Reproducible demo or steps to reproduce from a blank project

import { Auth } from 'aws-amplify'

const handleSignIn = async () => {
  Auth.signIn(email, password).then(resp => console.log(resp)
}

timhbt avatar Nov 11 '21 18:11 timhbt

I am having almost same issue for signing in via google. my reproducible example is as fellow:

  import * as GoogleSignIn from "expo-google-sign-in";

   const googleSignIn =async () => {

   try {
   const token = await _signInAsyncGoogle();

 //here i send this token to my backend
  } catch (e) {

await GoogleSignIn.signOutAsync();

  }
 };


 const _signInAsyncGoogle = async () => {
//Configures how the GoogleSignIn module will attempt to sign in.
//We arent providing any options. It will configure from google.json file downloaded from firebase
try {
await GoogleSignIn.initAsync();

//Android Only, this method always returns true on iOS
//This method will present a modal for the user to update Play Services if they aren't already up-to-date.
//Returns true after the user successfully updates.
Platform.OS == "android" && (await GoogleSignIn.askForPlayServicesAsync());
//Starts the native authentication flow with the information provided in GoogleSignIn.initAsync()
const { user } = await GoogleSignIn.signInAsync();
const token = user?.auth?.idToken;
return token;
  } catch (error) {
console.log("error in google = ", error);
   }
};

This worked perfectly fine in classic expo build. but since i migrated to eas no request is being sent to backend server

basit3407 avatar Nov 12 '21 02:11 basit3407

here is my example project. team expo can clone and test it. https://github.com/basit3407/expo-google-signInTest

basit3407 avatar Nov 12 '21 10:11 basit3407

It works for me now. Looked a bit deeper with expo-dev-client and become this error: [Unhandled promise rejection: Error: Error: Could not find a native getRandomBase64 implementation. Validate that amazon-cognito-identity-js is linked.]

So I had to install cognito-identity-js contradictory to the aws tutorial unter tap Expo. But I don't know why it works before with expo build without installing this library.

timhbt avatar Nov 12 '21 11:11 timhbt

@timhubert - on expo build we include the native code for amazon-cognito-identity-js. it seems like we need to update the aws tutorial to provide more information on this. we may also want to add this to our migration guide

brentvatne avatar Nov 16 '21 17:11 brentvatne

https://docs.expo.dev/build-reference/migrating/#amazon-cognito-identity-js--is-required-if-you-use

brentvatne avatar Dec 06 '21 20:12 brentvatne

The AWS Amplify docs still don't explain any of this, nor FWIW do they explain how to get DataStore working (which I have now wasted three days trying to do).

orome avatar May 18 '22 14:05 orome

@orome - you may want to post an issue about this on aws amplify docs. feel free to ping me in the issue and let them know that I am happy to help them improve the docs

brentvatne avatar May 21 '22 18:05 brentvatne

@brentvatne the doc you shared says we need to link the package? Can we do this with managed builds?

mikeRChambers610 avatar Sep 01 '22 20:09 mikeRChambers610

@mikeRChambers610 It's automatically linked. You only need to install the package amazon-cognito-identity-js.

timhbt avatar Sep 12 '22 15:09 timhbt

It works for me now. Looked a bit deeper with expo-dev-client and become this error: [Unhandled promise rejection: Error: Error: Could not find a native getRandomBase64 implementation. Validate that amazon-cognito-identity-js is linked.]

So I had to install cognito-identity-js contradictory to the aws tutorial unter tap Expo. But I don't know why it works before with expo build without installing this library.

did you resolve this?

popoviciyoel avatar Jul 22 '23 14:07 popoviciyoel