Skip to content

Unhandled Promise Rejection on OAuth for Auth0OAuthOpts  #8870

Open
@cyim02

Description

@cyim02

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Authentication

Amplify Categories

Not applicable

Environment information

# Put output below this line
"@aws-amplify/api": "^4.0.14",
"@aws-amplify/auth": "^4.3.4",
"@aws-amplify/core": "^4.2.8",
"react-native": "0.64.2"

Describe the bug

When using Auth0OAuthOpts rather than AwsCognitoOAuthOpts (shown below), an unhandled promise rejection error occurred.

Referenced:
https://github.com/aws-amplify/amplify-js/blob/main/packages/auth/src/types/Auth.ts#L131

export interface AwsCognitoOAuthOpts {
domain: string;
scope: Array;
redirectSignIn: string;
redirectSignOut: string;
responseType: string;
options?: object;
urlOpener?: (url: string, redirectUrl: string) => Promise;
}

export function isCognitoHostedOpts(
oauth: OAuthOpts
): oauth is AwsCognitoOAuthOpts {
return (oauth).redirectSignIn !== undefined;
}

export interface Auth0OAuthOpts {
domain: string;
clientID: string;
scope: string;
redirectUri: string;
audience: string;
responseType: string;
returnTo: string;
urlOpener?: (url: string, redirectUrl: string) => Promise;
}

export type OAuthOpts = AwsCognitoOAuthOpts | Auth0OAuthOpts;

Expected behavior

Using Auth0OAuthOpts should behave the same as AwsCognitoOAuthOpts, such as opening the WebUI.

Reproduction steps

  1. Use below Amplify OAuth Config:

oauth: {

domain: auth0_domain,
clientID: auth0_client_id,
scope: 'email openid',
redirectUri: auth0CallbackUri,
responseType: 'code',
returnTo: auth0CallbackUri,

},

  1. Call the below API

Auth.federatedSignIn({customProvider: 'auth0'})

  1. An Unhandled Promise Rejection error occurred

Code Snippet

// Put your code below this line.

Log output

// Put your logs below this line
WARN  Possible Unhandled Promise Rejection (id: 0):
TypeError: Cannot read property 'oauthSignIn' of undefined


aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    AuthRelated to Auth components/categoryCognitoRelated to cognito issuesService TeamIssues asked to the Service Teamfeature-requestRequest a new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions