Giter Club home page Giter Club logo

cognito-react's Introduction

Sample Web Application

Getting Started

The open-source Amplify Framework provides the following products to build fullstack iOS, Android, Flutter, Web, and React Native apps:

  • Amplify CLI - Configure all the services needed to power your backend through a simple command line interface.
  • Amplify Libraries - Use case-centric client libraries to integrate your app code with a backend using declarative interfaces.
  • Amplify UI Components - UI libraries for React, React Native, Angular, Ionic and Vue.

The Amplify Console is an AWS service that provides a git-based workflow for continuous deployment & hosting of fullstack web apps. Cloud resources created by the Amplify CLI are also visible in the Amplify Console.

Install and configure Amplify CLI

First we need to make sure we have npm installed to be able to install the amplify cli:

npm install -g @aws-amplify/cli

Within the code directory install all the necessary dependencies by running

npm install

Initilaize the project by running:

amplify init

Once Amplify has been initialized we are now ready to deploy the first backend service. To do this, we can leverage the hosting backend service by running the following command from the root of the project

amplify add hosting

For the purpose of simplicity, the following options “Hosting with Amplify Console” and “Manual Deployment” can be chosen when prompted for the selections.

To create the necessary backend resources to deploy the application using Amplify, please run the below command

amplify publish

Note: After successful deployment of the application, please update the callback and Signout URL in Cognito user pool with the web application URL.

At this stage the application is still non-functional as it needs to be updated with the configuration below.

Configure the application

In src/App.js you can enter the configuration parameters as follows:

Amplify.configure({
  Auth: {
    region: "<enter the region here>",
    userPoolId: "<enter the cognito user pool id here>",
    userPoolWebClientId: "<enter the applicaiton client id>",
    oauth: {
      domain: "<enter here the amazon cognito domain>",
      scope: ["email", "openid", "aws.cognito.signin.user.admin", "profile"],
      redirectSignIn: "<enter here the amplify hosted url>",
      redirectSignOut: "<enter here the amplify hosted url>",
      responseType: "code"
    }
  },
  API: {
    endpoints: [
      {
        name: "MyBlogPostAPI",
        endpoint: "<enter here the API gateway endpoint url>"
      }
    ]
  }
});

Also, you need to select the right Identity Provider Name as configured on Amazon Cognito. To do so, please modify the const variable, also located in the src/App.js file:

const federatedIdName =
  "<name of the Identity Provider as configured in Cognito>";

Once you set the right values you are ready to publish your code to amplify. You can submit your changes by running the following command

amplify publish

cognito-react's People

Contributors

salimdr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.