question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

REST API call not taking place when Auth & API used simultaneously inside Amplify.configure block. Page needs to be re-loaded manually to get data on the page after authentication.

See original GitHub issue

Post authentication React page is getting stuck with loading status as REST API call is not taking place and hence page needs to get re-loaded manually for REST API call to take place. There are no suggestions on how to handle both Auth & REST API call manually in Amplify.configure block. Tried using the suggested methods on - https://docs.amplify.aws/lib/graphqlapi/create-or-re-use-existing-backend/q/platform/js#using-openid_connect , but no luck. Can someone please suggest an alternative or suggest on how to get this fixed.

Amplify.configure({

  Auth: {
    region: 'us-east-1',
    userPoolId: process.env.REACT_APP_USERPOOL_ID,
    userPoolWebClientId: process.env.REACT_APP_USERPOOL_WEB_CLIENT_ID,

    oauth: {
      "domain": "xxxxx-dev.auth.us-east-1.amazoncognito.com",
      "scope": [
          "phone",
          "email",
          "openid",
          "profile",
          "aws.cognito.signin.user.admin"
      ],
      "redirectSignIn": "http://localhost:3000/",
      "redirectSignOut": "http://localhost:3000/",
      "responseType": "code",
    }
  },  

  API: {
    endpoints: [
      {
        name: "MyAPIGatewayAPI",
        endpoint: process.env.REACT_APP_APIG_ENDPOINT,
        region: 'us-east-1',
        custom_header: async () => {
          return { Authorization: (await Auth.currentSession()).idToken.jwtToken }; 
        }
      }
    ]
  }
  }); 
  

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ranopriyo-neogycommented, Nov 19, 2020

Thanks a ton @amhinson , upgrading the versions fixed the Loading issue.

0reactions
github-actions[bot]commented, Nov 20, 2021

This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Calling REST Api that requires auth from localhost ... - GitHub
The problem occurs if I reload the page. Either manually or because of live reload after changing something in the frontend code. If...
Read more >
API (REST) - Getting started - JavaScript - AWS Amplify Docs
Manual Setup: Reference existing REST API​​ For manual configuration you need to provide your AWS Resource configuration and optionally configure authentication.
Read more >
AWS Amplify Fullstack Project Setup (React, Node ... - YouTube
AWS Amplify is a CLI toolchain to help you build and deploy applications quickly. In this Step by Step Tutorial video, I show...
Read more >
API - Guide - SoundCloud Developers
In order to integrate with Soundcloud you need to authorize your application. SoundCloud authentication uses OAuth 2.0, a popular open standard used by...
Read more >
AWS Amplify: Using Existing Auth and API Resources
In this post, let's explore how we can configure a Cognito Pool for user authorization, a RESTful API with ApiGateway, and finally connect ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found