Question about manual configure Amplify to sign in against Identity pool / User pool.
New to the javascript world so deleted a few npm packages and had to re-install aws-amplify + aws-amplify-react-native.
And my sign-in stopped working, for no aparent reason (to me, that is :)).
From the beginning I used the Mobile Hub in AWS. But I dont really want all those features and CloudFront + S3 storage and such. So re-created a Cognito User Pool and an Identity Pool that uses that User Pool.
But I'm getting the same errors that I got when I by misstake deleted aws-amplify modules. And that is:
[ERROR] Authenticator - No userPool
The complete log (minus timestamp and some key info missing):
2018-03-01 20:24:54.052 [info][tid:main][RCTCxxBridge.mm:902] Invalidating <RCTCxxBridge: 0x6040001d96e0> (parent: <RCTBridge: 0x6000000d1db0>, executor: (null))
2018-03-01 20:24:54.053 [info][tid:main][RCTCxxBridge.mm:210] Initializing <RCTCxxBridge: 0x6000003ccb70> (parent: <RCTBridge: 0x6000000d1db0>, executor: (null))
2018-03-01 20:24:54.054 [warn][tid:main][RCTModuleData.mm:69] Module RCTImageLoader requires main queue setup since it overrides `init` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
2018-03-01 20:24:55.055 [info][tid:com.facebook.react.JavaScript] Load I18n module
2018-03-01 20:24:55.168 [info][tid:com.facebook.react.JavaScript] [DEBUG] 24:55.167 AuthClass - configure Auth
2018-03-01 20:24:55.169 [info][tid:com.facebook.react.JavaScript] [DEBUG] 24:55.168 I18n - configure I18n
2018-03-01 20:24:55.169 [info][tid:com.facebook.react.JavaScript] [DEBUG] 24:55.168 I18n - create I18n instance
2018-03-01 20:24:55.169 [info][tid:com.facebook.react.JavaScript] [DEBUG] 24:55.168 AnalyticsClass - configure Analytics
2018-03-01 20:24:55.169 [info][tid:com.facebook.react.JavaScript] [DEBUG] 24:55.168 AnalyticsClass - Do not have appId yet.
2018-03-01 20:24:55.169 [info][tid:com.facebook.react.JavaScript] [DEBUG] 24:55.169 API - configure API
2018-03-01 20:24:55.169 [info][tid:com.facebook.react.JavaScript] [DEBUG] 24:55.169 API - create API instance
2018-03-01 20:24:55.171 [info][tid:com.facebook.react.JavaScript] { '[DEBUG] 24:55.169 RestClient - API Options':
{ aws_cognito_identity_pool_id: 'XXXXXXXXXXX',
aws_cognito_region: 'eu-west-1',
aws_project_region: 'eu-west-1',
aws_sign_in_enabled: 'enable',
aws_user_pools: 'enable',
aws_user_pools_id: 'eu-west-XXXXXXXXXXX',
aws_user_pools_mfa_type: 'OFF',
aws_user_pools_web_client_id: 'XXXXXXXXXXX',
region: 'eu-west-1',
header: {} } }
2018-03-01 20:24:55.171 [info][tid:com.facebook.react.JavaScript] [DEBUG] 24:55.171 Storage - configure called
2018-03-01 20:24:55.171 [info][tid:com.facebook.react.JavaScript] [DEBUG] 24:55.171 StorageClass - configure Storage
2018-03-01 20:24:55.171 [info][tid:com.facebook.react.JavaScript] [DEBUG] 24:55.171 StorageClass - Do not have bucket yet
2018-03-01 20:24:55.172 [info][tid:com.facebook.react.JavaScript] [DEBUG] 24:55.171 StorageClass - configure Storage
2018-03-01 20:24:55.172 [info][tid:com.facebook.react.JavaScript] [DEBUG] 24:55.171 StorageClass - Do not have bucket yet
2018-03-01 20:24:55.196 [info][tid:main][RCTRootView.m:302] Running application App ({
initialProps = {
};
rootTag = 11;
})
2018-03-01 20:24:55.202 [info][tid:com.facebook.react.JavaScript] Running application "App" with appParams: {"rootTag":11,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
2018-03-01 20:24:55.254 [info][tid:com.facebook.react.JavaScript] [ERROR] Authenticator - No userPool
I have seem some various config options in various readmes/guides. So quite unsure exactly what is the best way to do it.
I tried just switching out stuff from the aws-export.js file (as the info is above) to correlate with the new user pool / identity etc.
But I also tried following https://aws.github.io/aws-amplify/media/install_n_config.html.
I'm wrapping the program in the withAuthenticator and I'm at a loss here to what might be wrong. So any help to this react and amplify newbie would be appreciated! :)
Everything except withAuthenticator is grabbed from aws-amplify and not aws-amplify-react-native.
Using version 0.2.9 of amplify and 0.1.24 of amplify-react-native.
Since the problem started without any changes in AWS I dont think anything is wrong with my user-pool + identity setup (but please let me know if there is anything you need to do when setting these up manually that I might haved missed).
It started when I removed what I thought was an unnecessary npm packaged called "fs". with npm remove fs
and it for some reason removed both aws-amplify
and aws-amplify-react-native
.
I have since removed my node_modules, cleared npm cache. run npm install
. But still no luck.
Thankful for any help!
I have sinced created a new awsmobile hub with signin, configured amplify with aws-export.js but still same error. Have no clue what could be wrong. The debug message doesn't say much.
The only thing I can think of is that it configures the RestClient instead of the AuthClass?
Ok, so I think I found the issue.
npm had also removed amazon-cognito-auth-js
. So I had to run npm install --save amazon-cognito-auth-js
and then unlink and link it. After that auth started working again.
@nuttmeister looks like you are using the hosted ui. This is something we are working on integrating. Could you possibly share your use case and how you are implementing the cognito auth sdk with amplify?
@mlabieniec honestly just played around with cognito and react-native using the mobile hub. but the mobile hub seemed a bit excessive tbh. So right now I'm only using cognito user pool + identity pool for authing + singing http requests.
@nuttmeister @mlabieniec I also got this "no user pool" error today on Amplify.SignUp and SignIn after updating my npm packages. I'm using MobileHub web interface to manage a wide range of AWS services as the serverless backend for ReactNative customer app, and a React web admin app. It seems most problems go away if you cut out the Amplify layer, and just use the more rigorous AWS SDK for javascript.
I'm getting a 'No userPool' error with the orange tag right now...I have no idea what happened, it was working fine, and then when I deleted the graphql package it stopped working, even after i re-added the same package, same version back. I'm not sure if it was directly related or not.
I have checked my aws-exports file, and aws_user_pools
is indeed enabled, and aws_user_pools_id
matches the same pool id on my cognito settings.
I have also rerun awsmobile push
and checked the aws-exports file to be sure.
I just checked out my entire repository, undoing every change I've made in the last hour (when it was still working) and it still doesn't work.
Note: I started with the aws mobilehub sample react app.
@supermikol same issue here. Just started working with sample react app today. No luck for me so far, continuing searching...
Actually looks like it was because the dependency issues were screwed up with my uninstalling of graphql. I reverted back to my older yarn.lock file and did a complete install and things seem to be working.
@bilal-korir what kind of issues are you running into? I ran into my fair share of bugs and spent some time configuring the app to make it working.
Good to hear that you got it to work back @supermikol . In my case, I followed the instructions written in the official Git repo, I made sure that user sign-in is enabled in the CLI, aws-exports.js, Mobile hub console, and in the Cognito console. When I try to sign up through the web page I receive the error "no userPool" just like yours. Would you please share your yarn.lock for comparison
Got the same - just started using the sample react app.
"amazon-cognito-auth-js": "^1.2.0",
"amazon-cognito-identity-js": "^1.31.0",
"aws-amplify": "^0.1.36",
"aws-amplify-react": "^0.1.43",
Anyone got any clues?
@setuk The sample react app didn't work for me, there was a bug authenticating the user. Instead, I started with an empty project folder and I used AWS Mobile CLI to create a serverless app on AWS, add features/services to my serverless app one by one, create my React app, install/add Amplify API package to my react app, and last put all together. General steps I followed go like this:
$ create-react-app magic-app
$ cd magic-app
$ npm install aws-amplify --save
$ awsmobile configure
set your AWS credentials and the region where to deploy your app$ awsmobile init
create a serverless app $ awsmobile features
add features you need to your app$ awsmobile run
push your update to the backend and run your react app@bilal-korir Thanks for your help. I will also try that route. I only wanted to see if there was a quick and easy way of autogenerating an interface into a DynamoDb table and it turned into a journey down the path of javascript dependency hell!
I got it working in the end after googling around.
Started with the following in package.json:-
"aws-amplify": "^0.1.36",
"aws-amplify-react": "^0.1.43",
• yarn install
• Yarn remove aws-amplify
• Yarn remove aws-amplify-react
• Yarn add aws-amplify
• Yarn add aws-amplify-react
Ended with the following in package.json:-
"aws-amplify": "^0.4.1",
"aws-amplify-react": "^0.1.47",
awsmobile run
Logging in and gets past No user pool - error.
@setuk it is good that you found a fix around it, hope who will come across the same issue can use it. In my case, I've already finished my project, but definitely, I'll keep it in mind for the future project. Thanks for sharing your solution
@bilal-korlr I just tried your instruction after I ran into the "no userpool" issue.
Really would like to take a look at this app running in my own aws resources.
much thanks.
user$ awsmobile push
checking the backend contents
Warning: no codebase found for lambda function: sampleCloudApi/items: sampleLambda
Warning: no codebase found for lambda function: sampleCloudApi/items/{proxy+}: sampleLambda
generating backend project content
_stream_readable.js:545
switch (state.pipesCount) {
^
TypeError: Cannot read property 'pipesCount' of undefined
@whatsdis I just re-edited my previews comment for better clarity. About the user registration feature, these are the steps how I did it:
$ create-react-app magic-app
$ cd magic-app
$ npm install aws-amplify --save
$ awsmobile configure
set your AWS credentials and the region where to deploy your app$ awsmobile init
create a serverless app $ awsmobile user-signin enable
add user sign in to your app$ awsmobile push
sync your local update with the backendHere is a snippet on my code
In index.js file
import Amplify from 'aws-amplify';
import config from './aws-exports';
Amplify.configure(config);
In SignUP.js component file
import {Auth} from 'aws-amplify';
import React, {Component} from 'react';
class SignUp extends Component {
state = {
username: '',
password: '',
email: '',
phone_number: '',
authCode: '',
}
signUp = () => {
const { username, password, email, phone_number } = this.state;
Auth.signUp({
username,
password,
attributes: {
email,
phone_number
}
})
.then(() =>this.setState(() => {return {showConfirmationForm: true}});)
.catch(error => console.log('Error singing up: ', error));
}
confirmSignUp = () => {
Auth.confirmSignUp(this.state.username, this.state.authCode)
.then(() => this.props.history.push('/home'))
.catch(error => console.log('Error confirming signing up: ', error))
}
next
$ awsmobile run
update backend if there are any, and launch your react app$ npm start
launch your react appHere is a nice useful tutorial I learned from, with more details
I was getting the same error after the move to amplify
instead of awsmobile
. My issue was I put the directory for the ./aws-exports
file at the root of the project, not in the src
file.
I moved the file to my src
then when I tried to run amplify add auth
it created a new aws-exports
file at my project root. The one I was importing was in the src directory, and was outdated by the previous command. Moral of my story is: when you run amplify init
pick the right folder and leave the aws-exports
file alone.
+1
I just amplify delete -> deleted all my node modules folder -> package.json (lock file) -> reinitiated the project amplify init. Things worked again. But not sure what the issue with the automated process. Maybe manually set up the things might work properly
Most helpful comment
@bilal-korir Thanks for your help. I will also try that route. I only wanted to see if there was a quick and easy way of autogenerating an interface into a DynamoDb table and it turned into a journey down the path of javascript dependency hell!
I got it working in the end after googling around.