aws-federated-login
TypeScript icon, indicating that this package has built-in type declarations

1.1.19 • Public • Published

aws-federated-login

Amazon Federated Login Client

Installation

npm i aws-federated-login

Introduction

With this package you can choose between popup and redirection during federated login via AWS

API:

1. awsFederatedLogin

trigger popup function Detailed meaning of fields

interface LoginParams {
    awsAuthorizedUrl: string;
    client_id: string;
    identity_provider: string;
    redirect_uri: string;
    response_type: string;
    scope: string;
    mode?: 'popup' | 'redirect'; // default 'redirect'
    callback: (params: any) => void;
}
export declare const awsFederatedLogin: (loginParams: LoginParams) => void;

2. awsRedirect:

popup middle page send message to the callback function that triggers the popup function

export declare const awsRedirect: () => void;

Demo

// trigger popup page
import { awsFederatedLogin } from 'aws-federated-login'
<button
    onClick={() => {
        awsFederatedLogin({
            awsAuthorizedUrl: 'https://XXX.amazoncognito.com/oauth2/authorize',
            client_id: 'XXX',
            identity_provider: 'Google', // 'Google' 'Facebook'
            redirect_uri: 'http://localhost:3000/pages/callback.html',
            response_type: 'CODE',
            scope: 'email openid phone',
            mode: 'popup',
            callback: (response) => {
                console.log('response is:', response)
            }
        })
    }
>
</button>
// callback.html
import { awsFederatedLogin } from 'aws-federated-login'
awsRedirect()

Package Sidebar

Install

npm i aws-federated-login

Weekly Downloads

2

Version

1.1.19

License

MIT

Unpacked Size

7.47 kB

Total Files

5

Last publish

Collaborators

  • yingsongtys