by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Gaurang Bhatt
    @GaurangBhatt

    Hello, I am stuck with the below error when using aws-amplify in my react app. Auth.signIn is returning the confirmed user from cognito pool. I also receive the verification code via SMS. However, when I try to call Auth.sendCustomChallengeAnswer I am getting below error. Note that Auth.signIn and Auth.sendCustomChallengeAnswer are in two different methods. Please advise.

    code
    `
    handleSignIn = (a) => (param) => (e) => {
    if (this.validator.fieldValid('First Name')
    && this.validator.fieldValid('Last Name')
    && this.validator.fieldValid('Phone Number')) {

      let username = "+01" + this.state.phoneNumber.replace(/[^\d]/g, '');
      Auth.signIn({
          username, // Required, the username
      }).then(user => {
        console.log(user);
        this.setState({
          ['formActivePanel' + a]: param,
          ['formActivePanel' + a + 'Changed']: true,
          cognitoUser: user,
        });
      })
      .catch(err => {
        console.log(err);
        //TODO Handle ERROR
      });
    } else {
      this.validator.showMessageFor('First Name');
      this.validator.showMessageFor('Last Name');
      this.validator.showMessageFor('Phone Number');
    }

    }

    handleVerify = () => {
    if (this.validator.fieldValid('Verification code')) {
    let challengeResponse = "123456";//this.state.otpCode;
    let user = this.state.cognitoUser;
    console.log("otpCode:" + challengeResponse);
    console.log(this.state.cognitoUser);

      Auth.sendCustomChallengeAnswer({
        user,
        challengeResponse,
      }).then(user => {
        console.log(user);
      })
      .catch(err => {
        console.log(err);
        //TODO Handle ERROR
      });
    
    } else {
      this.validator.showMessageFor('Verification code');
    }

    }
    `

    ERROR
    [ERROR] 57:50.242 AuthError - Challenge response cannot be empty

    Guilherme Campos
    @gpirescampos
    @GaurangBhatt in order to confirm the registration after receiving the code, I'm using Auth.confirmSignUp not Auth. sendCustomChallengeAnswer. I'm using email confirmation though, not sure if that changes anything
    Gaurang Bhatt
    @GaurangBhatt
    @gpirescampos thanks for quick response. I will try that.
    Guilherme Campos
    @gpirescampos
    This is the actual line await Auth.confirmSignUp(email, code, { forceAliasCreation: true })
    Gaurang Bhatt
    @GaurangBhatt
    Thanks. I am working on login so trying Auth.confirmSignIn

    Now I get below error.. the same thing just that instead of the challenge it is complaining about confirmation code. Console log clearly shows that it is receiving not-null confirmation code

    AuthError - Confirmation code cannot be empty console.<computed> @ index.js:1 ConsoleLogger._log @ ConsoleLogger.ts:91 ConsoleLogger.error @ ConsoleLogger.ts:142 AuthError @ Errors.ts:34 AuthClass.rejectAuthError @ Auth.ts:1976 AuthClass.confirmSignIn @ Auth.ts:889 Header.handleVerify @ Header.js:115

    Guilherme Campos
    @gpirescampos
    Then I guess you must have some sort of parsing error somewhere, and the code isn't being sent correctly. Try, for example, inserting a string where the code goes, and see if you don't get the error anymore. If you stop getting that error, then it's parsing. IF not, then I don't really know
    Gaurang Bhatt
    @GaurangBhatt

    Got past that error... It was related to parsing and how I was sending parameters to sendCustomChallengeAnswer.
    Error
    Auth.sendCustomChallengeAnswer({ user, challengeResponse, })

    Fix -- I had to set otp to String(user inputed value) otherwise I get serialization error
    Auth.sendCustomChallengeAnswer(user, otp)

    Udit Bhatia
    @uditbhatia
    my ampllfy init is failing with error
    init failed
    TypeError [ERR_INVALID_ARG_TYPE]: The 'request' argument must be string. Received type undefined
    Ruslan
    @irsqw_twitter
    hi
    is there any limit of how many relations can be returned when you request something with API.graphql(graphqlOperation))?
    so far I have 3 relations that must be returned when I a request a user, but I get only 2. User has many posts, each post has many comments and each comment has many reactions.
    for some reasons reactions are not returned
    the relation is set up correctly, all keys are present
    seems like it has something to do with the deepness of the relations returned
    Guilherme Campos
    @gpirescampos
    neelabja sen sarma
    @neelabja.sarma_gitlab
    I am getting error when calling lex service from nodejs."message":"Authorization header requires existence of either a 'X-Amz-Date' or a 'Date' header. I am able to hit it from postman. And i have generated the code from Postman itself.
    nissane
    @nissane
    I am trying to implement the amplify react HOC to use AWS cognito. I have followed the guides, but no matter what settings I use, after I authenticate, I am getting back an idtoken, refreshToken, and a accessToken. I only want to get back an access code. I have set my Amplify.configure to { oauth : {responseType: 'code'}} but that does not seem to be doing anything.
    smshiv
    @smshiv
    I am getting following exception when I run amplify init

    init failed
    { Error: write EPROTO 140718692255552:error:14094419:SSL routines:ssl3_read_bytes:tlsv1 alert access denied:ssl/record/rec_layer_s3.c:1543:SSL alert number 49

    at WriteWrap.afterWrite (net.js:788:14)

    message:
    'write EPROTO 140718692255552:error:14094419:SSL routines:ssl3_read_bytes:tlsv1 alert access denied:ssl/record/rec_layer_s3.c:1543:SSL alert number 49\n',
    errno: 'EPROTO',
    code: 'NetworkingError',
    syscall: 'write',
    region: 'ap-southeast-2',
    hostname: 'amplify.ap-southeast-2.amazonaws.com',
    retryable: true,
    time: 2020-01-27T14:37:23.039Z }

    Daniel S. Dantas
    @dantasfiles
    @aaronfay when you put @versioned in a model, it adds a version field to the model and puts some extra logic in the createX, updateX, and deleteX resolvers. Otherwise, the version field is like any other field for queries.
    William Rust
    @willrust
    I'm confused about what to expect from amplify add hosting when I have 2 environments (dev & master). When adding hosting I have the option of DEV & PROD, where PROD would be using CloudFront and HTTPS. My expectation is that after merging my dev and master envs, that only 1 of these hosting options will be used (whichever is merged in), so how should I quickly test out my dev env, if ultimately it should be deployed with CloudFront and HTTPS?
    Martin Juhasz
    @martinjuhasz
    Did anyone run into this issue before? I created a PostConfirmation Lambda (add-user-to-group) using the amplify cli, pushed it, but when it gets invoked it fails with a not authorized error. Seems like the created IAM user has no rights to call getGroup or createGroup on Cognito. Anyone had this before? Or how to resolve this?
    2 replies
    Marcin Kral
    @krlm
    Hi, I'm using Cognito to implement Single Sing On among a few web application (in different technologies, PHP, .NET, Java) and I'd like to provide custom login screen (app) for them - unfortunately customization of Cognito's build-in hosted UI is limited.
    I've found a lot of articles about customization of Amplify Auth UI itself, but I guess it's not what I'm looking for - To make SSO work I'd just need a single app to which other apps redirects (like hosted UI) which then authenticate user against user pool and redirects user back to the origin app. Unfortunately I cannot find any examples of such app, which is strange because I'd suppose that it's quite common requirement.
    Mickael Lecoq
    @mlecoq
    Hi, I am using amplify and Appsync. I would like to manage createdAt and updatedAt fields on server side (in order to avoid false values from clients) and to use them in indexes. Is it possible to define fields in @model in a read only mode (and automatic updates)
    Daniel S. Dantas
    @dantasfiles
    @martinjuhasz Make sure your amplify\backend\auth\XXX\XXX-cloudformation-template.yml has the right permissions (cognito-idp:AdminAddUserToGroup, cognito-idp:GetGroup, cognito-idp:CreateGroup) in the # Updating lambda role with permissions to Cognito section of the file. If not, you might want to redo the auth setup.
    Daniel S. Dantas
    @dantasfiles
    @mlecoq The Mutate.createX.req.vtl resolvers generated by Amplify have a line $util.qr($context.args.input.put("createdAt", $util.defaultIfNull($ctx.args.input.createdAt, $util.time.nowISO8601()))).
    You can change that to $util.qr($context.args.input.put("createdAt", $util.time.nowISO8601()))to prevent the user from overriding the createdAt value.
    Same with updatedAt in the updateX resolvers.
    I don't know a way to do it automatically in the model though.
    Mickael Lecoq
    @mlecoq
    @dantasfiles thanks I will try that
    shayaun-nejad
    @shayaun-nejad
    Hello, I am having troubles signing a federated identity to access my API Gateway on React-Native. I have enabled IAM authorization on my lambda endpoints. So the federated identity is returning the correct temporary credentials from AWS, and it is creating an authenticated session with Amplify. Also when I send a request via PostMan to API Gateway using these same credentials that are generated, it works. However, I am getting a 403 error when I send the request from my react native code
    I am pretty confident this is because the signing method on the request headers does not work
    from my axios request
    and I would like to use Amplify's API module but there is no easy way for me to specify the Authorization in the aws-configuration
    I have tried using libraries like aws4 to sign, but they seem to not be working as well
    any recommendations ?
    Martin Juhasz
    @martinjuhasz
    @dantasfiles thanks daniel. i figured that this endpoint gets not triggered when i create a user in the cognito interface, just when using signup. the errors i was getting resulted when testing it in the lambda interface with the test functionallity, somehow permissions are not present there. after signup it works fine
    BTW, are we able to send custom emails with amplify? especially the emails around signup, forgot-password, email etc. the only thing i found was the customMessage trigger which only lets you define some very minor details about the confirm email. but nothing else.
    Daniel S. Dantas
    @dantasfiles
    @martinjuhasz The Custom Message lets you put whatever you want in the email. https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-message.html
    Daniel S. Dantas
    @dantasfiles

    @shayaun-nejad you can specify the authorization for the API module manually with

    Amplify.configure({
      API: {
        graphql_headers: () => {
          return { Authorization: ... };
        },
      },
    });

    https://aws-amplify.github.io/docs/js/api#set-custom-request-headers-for-graphql

    Mickael Lecoq
    @mlecoq
    I do not understand why datastore never syncs with the cloud. I have tried with this example : https://github.com/dabit3/amplify-datastore-example (amplify init && amplify push && yarn start) and my DynamoDB tables are empty : data are only stored locally
    I read again and again the documentation and I don't see what is missing
    Mickael Lecoq
    @mlecoq
    Ok I must have one mistake in my schema, after removing most of the fields, connections and keeping just one entity (and simplifying auth), it works
    Ross Ragsdale
    @r0zar
    hello and good morning from the US
    has anyone here worked with adding custom claims to JWT tokens for Amplify APIs and Auth?
    Ross Ragsdale
    @r0zar
    I'm trying to add an array of strings as a claim, similiar to how cognito:groups is structured, but looks like im getting a Unrecognizable lambda output error
    Mickael Lecoq
    @mlecoq
    Hi, I am trying to use Datastore.observe to test automatic sync through several opened browser, and only local data is seen (not remote one) - is there any parameter to set to receive remote data through subscription ?
    Rodgco
    @rodgco
    Hi Amplify Community, is there a way to disable querying by id?
    I'm using Amplify API.
    Laff
    @KieranLafferty

    Hey everyone I've hit an issue connecting to a GraphQL subscription endpoint from my app. I'm using flutter connecting via a standard graphql client (not the amplify mobile client).

    Here's the error I'm getting

    flutter: Connecting to websocket: ws://localhost:20002/graphql...
    flutter: There was an error causing connection lost: WebSocketException: Connection to 'http://localhost:20002/graphql#' was not upgraded to websocket
    flutter: Disconnected from websocket.
    flutter: Scheduling to connect in 5 seconds...

    I'm attempting to connect to my local server after running amplify mock. In the logs I don't see any of the typical logs that I see when connecting through the Graphiql which leads me to believe I may have the wrong URL or something.

    The graphql is authenticated using Cognito jwt token and I've confirmed it's being sent properly

    I'm unsure if the subscription endpoint is supposed to be the same as the endpoint used for queries/mutations. Is this the case?