From 2d8df41c7707ac3f56a3e5d2f15b27dce3efa957 Mon Sep 17 00:00:00 2001 From: ManojNB Date: Wed, 4 Sep 2024 13:45:58 -0700 Subject: [PATCH 1/7] chore: add redirect section to sigout --- .../auth/add-social-provider/index.mdx | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/src/pages/gen1/[platform]/build-a-backend/auth/add-social-provider/index.mdx b/src/pages/gen1/[platform]/build-a-backend/auth/add-social-provider/index.mdx index 32916530850..84350ac10b0 100644 --- a/src/pages/gen1/[platform]/build-a-backend/auth/add-social-provider/index.mdx +++ b/src/pages/gen1/[platform]/build-a-backend/auth/add-social-provider/index.mdx @@ -739,6 +739,74 @@ function App() { +### Redirect URLs + +You can provide multiple _Sign in Redirect URI(s)_ & _Sign out redirect URI(s)_. + +If you have multiple redirect URI inputs, you'll need to pass them in your Amplify configuration. For example: + +```javascript +Amplify.configure({ + Auth: { + Cognito: { + loginWith: { + oauth: { + redirectSignIn: [ + 'myDevApp://' + ], + redirectSignOut: [ + 'myDevApp://', + 'myProdApp://' + ], + ...oauthConfig + } + }, + ...userPoolConfig + } + } +}); +``` + +#### Option to specify a redirect URL upon signOut +If you have multiple redirect urls configured, you may choose to override the default behavior of selecting a redirect url and provide the one of your choosing when calling `signOut`. The provided redirect url should match atleast one of the configured redirect urls. If no redirect url is provided to `signOut`, the first item from the the configured redirect urls list that does not contain a http nor https prefix will be picked. + +```ts +import { Amplify } from 'aws-amplify'; +import { signOut } from 'aws-amplify/auth'; + +Amplify.configure({ + Auth: { + Cognito: { + loginWith: { + oauth: { + redirectSignIn: [ + 'myDevApp://' + ], + redirectSignOut: [ + 'myDevApp://', + 'myProdApp://' + ], + ...oauthConfig + } + }, + ...userPoolConfig + } + } +}); + +function handleSignOut() { + signOut({ + global: false, + oauth: { + redirectUrl: 'myDevApp://' + } + }); +} + + +``` + Irrespective of whether a `redirectUrl` is provided to the `signOut`, an item that does not contain a http or https string is expected to be present in the configured redirect urls list. This is because iOS requires we provide an appScheme when creating the web session. + @@ -943,6 +1011,43 @@ function App() { +#### Option to specify a redirect URL upon signOut +If you have multiple redirect urls configured, you may choose to override the default behavior of selecting a redirect url and provide the one of your choosing when calling `signOut`. The provided redirect url should match atleast one of the configured redirect urls. If no redirect url is provided to `signOut`, one will be selected based on the current app domain. + +```ts +import { Amplify } from 'aws-amplify'; +import { signOut } from 'aws-amplify/auth'; + +Amplify.configure({ + Auth: { + Cognito: { + loginWith: { + oauth: { + redirectSignIn: [ + 'http://localhost:3000/', + 'https://www.example.com/' + ], + redirectSignOut: [ + 'http://localhost:3000/', + 'https://www.example.com/' + ], + ...oauthConfig + } + }, + ...userPoolConfig + } + } +}); + +signOut({ + global: false, + oauth: { + redirectUrl: 'https://www.example.com/' + } +}); + +``` + ### (Required for Multi-Page Applications) Complete Social Sign In after Redirect If you are developing a multi-page application, and the redirected page is not the same page that initiated the sign in, you will need to add the following code to the redirected page to ensure the sign in gets completed: From 313130c23244126d1a1367bebd95036279129152 Mon Sep 17 00:00:00 2001 From: ManojNB Date: Wed, 4 Sep 2024 13:56:59 -0700 Subject: [PATCH 2/7] chore: spell correction --- .../build-a-backend/auth/add-social-provider/index.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/gen1/[platform]/build-a-backend/auth/add-social-provider/index.mdx b/src/pages/gen1/[platform]/build-a-backend/auth/add-social-provider/index.mdx index 84350ac10b0..dcdcd940107 100644 --- a/src/pages/gen1/[platform]/build-a-backend/auth/add-social-provider/index.mdx +++ b/src/pages/gen1/[platform]/build-a-backend/auth/add-social-provider/index.mdx @@ -768,7 +768,7 @@ Amplify.configure({ ``` #### Option to specify a redirect URL upon signOut -If you have multiple redirect urls configured, you may choose to override the default behavior of selecting a redirect url and provide the one of your choosing when calling `signOut`. The provided redirect url should match atleast one of the configured redirect urls. If no redirect url is provided to `signOut`, the first item from the the configured redirect urls list that does not contain a http nor https prefix will be picked. +If you have multiple redirect urls configured, you may choose to override the default behavior of selecting a redirect url and provide the one of your choosing when calling `signOut`. The provided redirect url should match at least one of the configured redirect urls. If no redirect url is provided to `signOut`, the first item from the the configured redirect urls list that does not contain a http nor https prefix will be picked. ```ts import { Amplify } from 'aws-amplify'; @@ -1012,7 +1012,7 @@ function App() { #### Option to specify a redirect URL upon signOut -If you have multiple redirect urls configured, you may choose to override the default behavior of selecting a redirect url and provide the one of your choosing when calling `signOut`. The provided redirect url should match atleast one of the configured redirect urls. If no redirect url is provided to `signOut`, one will be selected based on the current app domain. +If you have multiple redirect urls configured, you may choose to override the default behavior of selecting a redirect url and provide the one of your choosing when calling `signOut`. The provided redirect url should match at least one of the configured redirect urls. If no redirect url is provided to `signOut`, one will be selected based on the current app domain. ```ts import { Amplify } from 'aws-amplify'; From f5bcc0802ac8b4c1da9351b4d1019269d1632f65 Mon Sep 17 00:00:00 2001 From: ManojNB Date: Thu, 5 Sep 2024 13:04:54 -0700 Subject: [PATCH 3/7] chore: address review comments --- .../auth/add-social-provider/index.mdx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/pages/gen1/[platform]/build-a-backend/auth/add-social-provider/index.mdx b/src/pages/gen1/[platform]/build-a-backend/auth/add-social-provider/index.mdx index dcdcd940107..9048bbc7ded 100644 --- a/src/pages/gen1/[platform]/build-a-backend/auth/add-social-provider/index.mdx +++ b/src/pages/gen1/[platform]/build-a-backend/auth/add-social-provider/index.mdx @@ -739,9 +739,9 @@ function App() { -### Redirect URLs +### Redirect URIs -You can provide multiple _Sign in Redirect URI(s)_ & _Sign out redirect URI(s)_. +You can provide multiple _Sign in_ & _Sign out_ redirect URI(s). If you have multiple redirect URI inputs, you'll need to pass them in your Amplify configuration. For example: @@ -767,7 +767,7 @@ Amplify.configure({ }); ``` -#### Option to specify a redirect URL upon signOut +#### Specifying a redirect URI on sign out If you have multiple redirect urls configured, you may choose to override the default behavior of selecting a redirect url and provide the one of your choosing when calling `signOut`. The provided redirect url should match at least one of the configured redirect urls. If no redirect url is provided to `signOut`, the first item from the the configured redirect urls list that does not contain a http nor https prefix will be picked. ```ts @@ -784,7 +784,7 @@ Amplify.configure({ ], redirectSignOut: [ 'myDevApp://', - 'myProdApp://' + 'https://oidcProvider/?logout_uri=myDevApp://' ], ...oauthConfig } @@ -798,22 +798,22 @@ function handleSignOut() { signOut({ global: false, oauth: { - redirectUrl: 'myDevApp://' + redirectUrl: 'https://oidcProvider/?logout_uri=myDevApp://' } }); } ``` - Irrespective of whether a `redirectUrl` is provided to the `signOut`, an item that does not contain a http or https string is expected to be present in the configured redirect urls list. This is because iOS requires we provide an appScheme when creating the web session. + Irrespective of whether a `redirectUrl` is provided to `signOut`, a URL that does not contain http or https is expected to be present in the configured redirect URL list. This is because iOS requires an appScheme when creating the web session. -### Redirect URLs +### Redirect URIs -For _Sign in Redirect URI(s)_ inputs, you can put one URI for local development and one for production. Example: `http://localhost:3000/` in dev and `https://www.example.com/` in production. The same is true for _Sign out redirect URI(s)_. +For _Sign in Redirect URI(s)_ inputs, you can put one URI for local development and one for production. Example: `http://localhost:3000/` in dev and `https://www.example.com/` in production. The same is true for _Sign out Redirect URI(s)_. If you have multiple redirect URI inputs, you'll need to pass them in your Amplify configuration. For example: @@ -1011,7 +1011,7 @@ function App() { -#### Option to specify a redirect URL upon signOut +#### Specifying a redirect URI on sign out If you have multiple redirect urls configured, you may choose to override the default behavior of selecting a redirect url and provide the one of your choosing when calling `signOut`. The provided redirect url should match at least one of the configured redirect urls. If no redirect url is provided to `signOut`, one will be selected based on the current app domain. ```ts From 772acce045e982cdc2001a4bbb958afed1978608 Mon Sep 17 00:00:00 2001 From: ManojNB Date: Thu, 5 Sep 2024 13:51:26 -0700 Subject: [PATCH 4/7] chore: add same sections to Gen2 docs --- .../external-identity-providers/index.mdx | 154 ++++++++++++++++++ .../auth/add-social-provider/index.mdx | 4 +- 2 files changed, 155 insertions(+), 3 deletions(-) diff --git a/src/pages/[platform]/build-a-backend/auth/concepts/external-identity-providers/index.mdx b/src/pages/[platform]/build-a-backend/auth/concepts/external-identity-providers/index.mdx index f56a392fb74..64d37fe6f14 100644 --- a/src/pages/[platform]/build-a-backend/auth/concepts/external-identity-providers/index.mdx +++ b/src/pages/[platform]/build-a-backend/auth/concepts/external-identity-providers/index.mdx @@ -387,6 +387,72 @@ await signInWithRedirect({ }); ``` +### Redirect URIs + +For _Sign in Redirect URI(s)_ inputs, you can put one URI for local development and one for production. Example: `http://localhost:3000/` in dev and `https://www.example.com/` in production. The same is true for _Sign out Redirect URI(s)_. + +If you have multiple redirect URI inputs, you'll need to pass them in your Amplify configuration. For example: + +```javascript +Amplify.configure({ + Auth: { + Cognito: { + loginWith: { + oauth: { + redirectSignIn: [ + 'http://localhost:3000/', + 'https://www.example.com/' + ], + redirectSignOut: [ + 'http://localhost:3000/', + 'https://www.example.com/' + ], + ...oauthConfig + } + }, + ...userPoolConfig + } + } +}); +``` + +#### Specifying a redirect URI on sign out +If you have multiple redirect urls configured, you may choose to override the default behavior of selecting a redirect url and provide the one of your choosing when calling `signOut`. The provided redirect url should match at least one of the configured redirect urls. If no redirect url is provided to `signOut`, one will be selected based on the current app domain. + +```ts +import { Amplify } from 'aws-amplify'; +import { signOut } from 'aws-amplify/auth'; + +Amplify.configure({ + Auth: { + Cognito: { + loginWith: { + oauth: { + redirectSignIn: [ + 'http://localhost:3000/', + 'https://www.example.com/' + ], + redirectSignOut: [ + 'http://localhost:3000/', + 'https://www.example.com/' + ], + ...oauthConfig + } + }, + ...userPoolConfig + } + } +}); + +signOut({ + global: false, + oauth: { + redirectUrl: 'https://www.example.com/' + } +}); + +``` + @@ -430,6 +496,94 @@ When you import and use the `signInWithRedirect` function, it will add a listene + + +## Set up your frontend + + + +If you are using the [Authenticator component](https://ui.docs.amplify.aws/react/connected-components/authenticator/configuration#external-providers) with Amplify, this feature works without any additional code. The guide below is for writing your own implementation. + + + +Use the `signInWithRedirect` API to initiate sign-in with an external identity provider. + +```ts title="src/my-client-side-js.js" +import { signInWithRedirect } from 'aws-amplify/auth'; + +await signInWithRedirect({ + provider: 'Apple' +}); +``` + +### Redirect URIs + +If you want to manually configure multiple _Sign in_ & _Sign out_ redirect URI(s), you'll need to pass them in your Amplify configuration. For example: + +```javascript +Amplify.configure({ + Auth: { + Cognito: { + loginWith: { + oauth: { + redirectSignIn: [ + 'myDevApp://' + ], + redirectSignOut: [ + 'myDevApp://', + 'myProdApp://' + ], + ...oauthConfig + } + }, + ...userPoolConfig + } + } +}); +``` + +#### Specifying a redirect URI on sign out +If you have multiple redirect urls configured, you may choose to override the default behavior of selecting a redirect url and provide the one of your choosing when calling `signOut`. The provided redirect url should match at least one of the configured redirect urls. If no redirect url is provided to `signOut`, the first item from the the configured redirect urls list that does not contain a http nor https prefix will be picked. + +```ts +import { Amplify } from 'aws-amplify'; +import { signOut } from 'aws-amplify/auth'; + +Amplify.configure({ + Auth: { + Cognito: { + loginWith: { + oauth: { + redirectSignIn: [ + 'myDevApp://' + ], + redirectSignOut: [ + 'myDevApp://', + 'https://oidcProvider/?logout_uri=myDevApp://' + ], + ...oauthConfig + } + }, + ...userPoolConfig + } + } +}); + +function handleSignOut() { + signOut({ + global: false, + oauth: { + redirectUrl: 'https://oidcProvider/?logout_uri=myDevApp://' + } + }); +} + + +``` + Irrespective of whether a `redirectUrl` is provided to `signOut`, a URL that does not contain http or https is expected to be present in the configured redirect URL list. This is because iOS requires an appScheme when creating the web session. + + + ## Next steps - [Learn how to sign in with external providers](/[platform]/build-a-backend/auth/connect-your-frontend/sign-in/#sign-in-with-an-external-identity-provider) diff --git a/src/pages/gen1/[platform]/build-a-backend/auth/add-social-provider/index.mdx b/src/pages/gen1/[platform]/build-a-backend/auth/add-social-provider/index.mdx index 9048bbc7ded..71bd0007989 100644 --- a/src/pages/gen1/[platform]/build-a-backend/auth/add-social-provider/index.mdx +++ b/src/pages/gen1/[platform]/build-a-backend/auth/add-social-provider/index.mdx @@ -741,9 +741,7 @@ function App() { ### Redirect URIs -You can provide multiple _Sign in_ & _Sign out_ redirect URI(s). - -If you have multiple redirect URI inputs, you'll need to pass them in your Amplify configuration. For example: +If you want to manually configure multiple _Sign in_ & _Sign out_ redirect URI(s), you'll need to pass them in your Amplify configuration. For example: ```javascript Amplify.configure({ From 188d514ebc60096d389de548889f2354f1f0e8f6 Mon Sep 17 00:00:00 2001 From: ManojNB Date: Thu, 5 Sep 2024 16:04:58 -0700 Subject: [PATCH 5/7] chore: minor corrections --- .../concepts/external-identity-providers/index.mdx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/pages/[platform]/build-a-backend/auth/concepts/external-identity-providers/index.mdx b/src/pages/[platform]/build-a-backend/auth/concepts/external-identity-providers/index.mdx index 64d37fe6f14..651a753d6d9 100644 --- a/src/pages/[platform]/build-a-backend/auth/concepts/external-identity-providers/index.mdx +++ b/src/pages/[platform]/build-a-backend/auth/concepts/external-identity-providers/index.mdx @@ -389,9 +389,9 @@ await signInWithRedirect({ ### Redirect URIs -For _Sign in Redirect URI(s)_ inputs, you can put one URI for local development and one for production. Example: `http://localhost:3000/` in dev and `https://www.example.com/` in production. The same is true for _Sign out Redirect URI(s)_. +For _Sign in Redirect URI(s)_ inputs, you can set one URI for local development and one for production. For example: `http://localhost:3000/` in dev and `https://www.example.com/` in production. The same is true for _Sign out Redirect URI(s)_. -If you have multiple redirect URI inputs, you'll need to pass them in your Amplify configuration. For example: +If you have multiple redirect URIs, you'll need to pass them in your Amplify configuration. For example: ```javascript Amplify.configure({ @@ -511,9 +511,12 @@ Use the `signInWithRedirect` API to initiate sign-in with an external identity p ```ts title="src/my-client-side-js.js" import { signInWithRedirect } from 'aws-amplify/auth'; -await signInWithRedirect({ - provider: 'Apple' -}); +function handleSignInWithRedirect() { + signInWithRedirect({ + provider: 'Apple' + }); +} + ``` ### Redirect URIs @@ -578,7 +581,6 @@ function handleSignOut() { }); } - ``` Irrespective of whether a `redirectUrl` is provided to `signOut`, a URL that does not contain http or https is expected to be present in the configured redirect URL list. This is because iOS requires an appScheme when creating the web session. From f644e2efd23b38dccd377bb0c8cd459627cae479 Mon Sep 17 00:00:00 2001 From: ManojNB Date: Thu, 5 Sep 2024 16:23:19 -0700 Subject: [PATCH 6/7] chore: convert URI to URL --- .../external-identity-providers/index.mdx | 14 +++++++------- .../auth/add-social-provider/index.mdx | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/pages/[platform]/build-a-backend/auth/concepts/external-identity-providers/index.mdx b/src/pages/[platform]/build-a-backend/auth/concepts/external-identity-providers/index.mdx index 651a753d6d9..9ff179294e7 100644 --- a/src/pages/[platform]/build-a-backend/auth/concepts/external-identity-providers/index.mdx +++ b/src/pages/[platform]/build-a-backend/auth/concepts/external-identity-providers/index.mdx @@ -387,11 +387,11 @@ await signInWithRedirect({ }); ``` -### Redirect URIs +### Redirect URLs -For _Sign in Redirect URI(s)_ inputs, you can set one URI for local development and one for production. For example: `http://localhost:3000/` in dev and `https://www.example.com/` in production. The same is true for _Sign out Redirect URI(s)_. +For _Sign in Redirect URL(s)_ inputs, you can set one URL for local development and one for production. For example: `http://localhost:3000/` in dev and `https://www.example.com/` in production. The same is true for _Sign out Redirect URL(s)_. -If you have multiple redirect URIs, you'll need to pass them in your Amplify configuration. For example: +If you have multiple redirect URLs, you'll need to pass them in your Amplify configuration. For example: ```javascript Amplify.configure({ @@ -416,7 +416,7 @@ Amplify.configure({ }); ``` -#### Specifying a redirect URI on sign out +#### Specifying a redirect URL on sign out If you have multiple redirect urls configured, you may choose to override the default behavior of selecting a redirect url and provide the one of your choosing when calling `signOut`. The provided redirect url should match at least one of the configured redirect urls. If no redirect url is provided to `signOut`, one will be selected based on the current app domain. ```ts @@ -519,9 +519,9 @@ function handleSignInWithRedirect() { ``` -### Redirect URIs +### Redirect URLs -If you want to manually configure multiple _Sign in_ & _Sign out_ redirect URI(s), you'll need to pass them in your Amplify configuration. For example: +If you want to manually configure multiple _Sign in_ & _Sign out_ redirect URL(s), you'll need to pass them in your Amplify configuration. For example: ```javascript Amplify.configure({ @@ -545,7 +545,7 @@ Amplify.configure({ }); ``` -#### Specifying a redirect URI on sign out +#### Specifying a redirect URL on sign out If you have multiple redirect urls configured, you may choose to override the default behavior of selecting a redirect url and provide the one of your choosing when calling `signOut`. The provided redirect url should match at least one of the configured redirect urls. If no redirect url is provided to `signOut`, the first item from the the configured redirect urls list that does not contain a http nor https prefix will be picked. ```ts diff --git a/src/pages/gen1/[platform]/build-a-backend/auth/add-social-provider/index.mdx b/src/pages/gen1/[platform]/build-a-backend/auth/add-social-provider/index.mdx index 71bd0007989..86c9f51d6e4 100644 --- a/src/pages/gen1/[platform]/build-a-backend/auth/add-social-provider/index.mdx +++ b/src/pages/gen1/[platform]/build-a-backend/auth/add-social-provider/index.mdx @@ -739,9 +739,9 @@ function App() { -### Redirect URIs +### Redirect URLs -If you want to manually configure multiple _Sign in_ & _Sign out_ redirect URI(s), you'll need to pass them in your Amplify configuration. For example: +If you want to manually configure multiple _Sign in_ & _Sign out_ redirect URL(s), you'll need to pass them in your Amplify configuration. For example: ```javascript Amplify.configure({ @@ -765,7 +765,7 @@ Amplify.configure({ }); ``` -#### Specifying a redirect URI on sign out +#### Specifying a redirect URL on sign out If you have multiple redirect urls configured, you may choose to override the default behavior of selecting a redirect url and provide the one of your choosing when calling `signOut`. The provided redirect url should match at least one of the configured redirect urls. If no redirect url is provided to `signOut`, the first item from the the configured redirect urls list that does not contain a http nor https prefix will be picked. ```ts @@ -809,11 +809,11 @@ function handleSignOut() { -### Redirect URIs +### Redirect URLs -For _Sign in Redirect URI(s)_ inputs, you can put one URI for local development and one for production. Example: `http://localhost:3000/` in dev and `https://www.example.com/` in production. The same is true for _Sign out Redirect URI(s)_. +For _Sign in Redirect URL(s)_ inputs, you can set one URL for local development and one for production. For example: `http://localhost:3000/` in dev and `https://www.example.com/` in production. The same is true for _Sign out Redirect URL(s)_. -If you have multiple redirect URI inputs, you'll need to pass them in your Amplify configuration. For example: +If you have multiple redirect URLs, you'll need to pass them in your Amplify configuration. For example: ```javascript Amplify.configure({ @@ -838,7 +838,7 @@ Amplify.configure({ }); ``` - + @@ -1009,7 +1009,7 @@ function App() { -#### Specifying a redirect URI on sign out +#### Specifying a redirect URL on sign out If you have multiple redirect urls configured, you may choose to override the default behavior of selecting a redirect url and provide the one of your choosing when calling `signOut`. The provided redirect url should match at least one of the configured redirect urls. If no redirect url is provided to `signOut`, one will be selected based on the current app domain. ```ts From 5014e27e6bb0abf7342111b86c2e08e3de3b884c Mon Sep 17 00:00:00 2001 From: ManojNB Date: Fri, 6 Sep 2024 16:55:01 -0700 Subject: [PATCH 7/7] chore: review comments --- .../external-identity-providers/index.mdx | 121 +++--------------- .../auth/add-social-provider/index.mdx | 110 ++-------------- 2 files changed, 31 insertions(+), 200 deletions(-) diff --git a/src/pages/[platform]/build-a-backend/auth/concepts/external-identity-providers/index.mdx b/src/pages/[platform]/build-a-backend/auth/concepts/external-identity-providers/index.mdx index 9ff179294e7..3b88d9d33cf 100644 --- a/src/pages/[platform]/build-a-backend/auth/concepts/external-identity-providers/index.mdx +++ b/src/pages/[platform]/build-a-backend/auth/concepts/external-identity-providers/index.mdx @@ -368,6 +368,7 @@ await signInWithRedirect({ + {/* @TODO refactor with connect-your-frontend/sign-in */} ## Set up your frontend @@ -389,65 +390,22 @@ await signInWithRedirect({ ### Redirect URLs -For _Sign in Redirect URL(s)_ inputs, you can set one URL for local development and one for production. For example: `http://localhost:3000/` in dev and `https://www.example.com/` in production. The same is true for _Sign out Redirect URL(s)_. - -If you have multiple redirect URLs, you'll need to pass them in your Amplify configuration. For example: - -```javascript -Amplify.configure({ - Auth: { - Cognito: { - loginWith: { - oauth: { - redirectSignIn: [ - 'http://localhost:3000/', - 'https://www.example.com/' - ], - redirectSignOut: [ - 'http://localhost:3000/', - 'https://www.example.com/' - ], - ...oauthConfig - } - }, - ...userPoolConfig - } - } -}); -``` +_Sign in_ & _Sign out_ redirect URL(s) are used to redirect end users after the sign in or sign out operation has occurred. You may want to specify multiple URLs for various use-cases such as having different URLs for development/ production or redirect users to an intermediate URL before returning them to the app. #### Specifying a redirect URL on sign out -If you have multiple redirect urls configured, you may choose to override the default behavior of selecting a redirect url and provide the one of your choosing when calling `signOut`. The provided redirect url should match at least one of the configured redirect urls. If no redirect url is provided to `signOut`, one will be selected based on the current app domain. +If you have multiple sign out redirect URLs configured, you may choose to override the default behavior of selecting a redirect URL and provide the one of your choosing when calling `signOut`. The provided redirect URL should match at least one of the configured redirect URLs. If no redirect URL is provided to `signOut`, one will be selected based on the current app domain. ```ts import { Amplify } from 'aws-amplify'; import { signOut } from 'aws-amplify/auth'; -Amplify.configure({ - Auth: { - Cognito: { - loginWith: { - oauth: { - redirectSignIn: [ - 'http://localhost:3000/', - 'https://www.example.com/' - ], - redirectSignOut: [ - 'http://localhost:3000/', - 'https://www.example.com/' - ], - ...oauthConfig - } - }, - ...userPoolConfig - } - } -}); +// Assuming the following URLS were provided manually or via the Amplify configuration file, +// redirectSignOut: 'http://localhost:3000/,https://authProvider/logout?logout_uri=https://mywebsite.com/' signOut({ global: false, oauth: { - redirectUrl: 'https://www.example.com/' + redirectUrl: 'https://authProvider/logout?logout_uri=https://mywebsite.com/' } }); @@ -511,76 +469,33 @@ Use the `signInWithRedirect` API to initiate sign-in with an external identity p ```ts title="src/my-client-side-js.js" import { signInWithRedirect } from 'aws-amplify/auth'; -function handleSignInWithRedirect() { - signInWithRedirect({ - provider: 'Apple' - }); -} +signInWithRedirect({ + provider: 'Apple' +}); ``` ### Redirect URLs -If you want to manually configure multiple _Sign in_ & _Sign out_ redirect URL(s), you'll need to pass them in your Amplify configuration. For example: - -```javascript -Amplify.configure({ - Auth: { - Cognito: { - loginWith: { - oauth: { - redirectSignIn: [ - 'myDevApp://' - ], - redirectSignOut: [ - 'myDevApp://', - 'myProdApp://' - ], - ...oauthConfig - } - }, - ...userPoolConfig - } - } -}); -``` +_Sign in_ & _Sign out_ redirect URL(s) are used to redirect end users after the sign in or sign out operation has occurred. You may want to specify multiple URLs for various use-cases such as having different URLs for development/ production or redirect users to an intermediate URL before returning them to the app. #### Specifying a redirect URL on sign out -If you have multiple redirect urls configured, you may choose to override the default behavior of selecting a redirect url and provide the one of your choosing when calling `signOut`. The provided redirect url should match at least one of the configured redirect urls. If no redirect url is provided to `signOut`, the first item from the the configured redirect urls list that does not contain a http nor https prefix will be picked. +If you have multiple sign out redirect URLs configured, you may choose to override the default behavior of selecting a redirect URL and provide the one of your choosing when calling `signOut`. The provided redirect URL should match at least one of the configured redirect URLs. If no redirect URL is provided to `signOut`, the first item from the the configured redirect URLs list that does not contain a HTTP nor HTTPS prefix will be picked. ```ts import { Amplify } from 'aws-amplify'; import { signOut } from 'aws-amplify/auth'; -Amplify.configure({ - Auth: { - Cognito: { - loginWith: { - oauth: { - redirectSignIn: [ - 'myDevApp://' - ], - redirectSignOut: [ - 'myDevApp://', - 'https://oidcProvider/?logout_uri=myDevApp://' - ], - ...oauthConfig - } - }, - ...userPoolConfig - } +// Assuming the following URLS were provided manually or via the Amplify configuration file, +// redirectSignOut: 'myDevApp://,https://authProvider/logout?logout_uri=myDevApp://' + +signOut({ + global: false, + oauth: { + redirectUrl: 'https://authProvider/logout?logout_uri=myDevApp://' } }); -function handleSignOut() { - signOut({ - global: false, - oauth: { - redirectUrl: 'https://oidcProvider/?logout_uri=myDevApp://' - } - }); -} - ``` Irrespective of whether a `redirectUrl` is provided to `signOut`, a URL that does not contain http or https is expected to be present in the configured redirect URL list. This is because iOS requires an appScheme when creating the web session. diff --git a/src/pages/gen1/[platform]/build-a-backend/auth/add-social-provider/index.mdx b/src/pages/gen1/[platform]/build-a-backend/auth/add-social-provider/index.mdx index 86c9f51d6e4..8d42c1c6764 100644 --- a/src/pages/gen1/[platform]/build-a-backend/auth/add-social-provider/index.mdx +++ b/src/pages/gen1/[platform]/build-a-backend/auth/add-social-provider/index.mdx @@ -741,66 +741,25 @@ function App() { ### Redirect URLs -If you want to manually configure multiple _Sign in_ & _Sign out_ redirect URL(s), you'll need to pass them in your Amplify configuration. For example: - -```javascript -Amplify.configure({ - Auth: { - Cognito: { - loginWith: { - oauth: { - redirectSignIn: [ - 'myDevApp://' - ], - redirectSignOut: [ - 'myDevApp://', - 'myProdApp://' - ], - ...oauthConfig - } - }, - ...userPoolConfig - } - } -}); -``` +_Sign in_ & _Sign out_ redirect URL(s) are used to redirect end users after the sign in or sign out operation has occurred. You may want to specify multiple URLs for various use-cases such as having different URLs for development/ production or redirect users to an intermediate URL before returning them to the app. #### Specifying a redirect URL on sign out -If you have multiple redirect urls configured, you may choose to override the default behavior of selecting a redirect url and provide the one of your choosing when calling `signOut`. The provided redirect url should match at least one of the configured redirect urls. If no redirect url is provided to `signOut`, the first item from the the configured redirect urls list that does not contain a http nor https prefix will be picked. +If you have multiple sign out redirect URLs configured, you may choose to override the default behavior of selecting a redirect URL and provide the one of your choosing when calling `signOut`. The provided redirect URL should match at least one of the configured redirect URLs. If no redirect URL is provided to `signOut`, the first item from the the configured redirect URLs list that does not contain a HTTP nor HTTPS prefix will be picked. ```ts import { Amplify } from 'aws-amplify'; import { signOut } from 'aws-amplify/auth'; -Amplify.configure({ - Auth: { - Cognito: { - loginWith: { - oauth: { - redirectSignIn: [ - 'myDevApp://' - ], - redirectSignOut: [ - 'myDevApp://', - 'https://oidcProvider/?logout_uri=myDevApp://' - ], - ...oauthConfig - } - }, - ...userPoolConfig - } +// Assuming the following URLS were provided manually or via the Amplify configuration file, +// redirectSignOut: 'myDevApp://,https://authProvider/logout/?logout_uri=myDevApp://' + +signOut({ + global: false, + oauth: { + redirectUrl: 'https://authProvider/logout/?logout_uri=myDevApp://' } }); -function handleSignOut() { - signOut({ - global: false, - oauth: { - redirectUrl: 'https://oidcProvider/?logout_uri=myDevApp://' - } - }); -} - ``` Irrespective of whether a `redirectUrl` is provided to `signOut`, a URL that does not contain http or https is expected to be present in the configured redirect URL list. This is because iOS requires an appScheme when creating the web session. @@ -811,32 +770,7 @@ function handleSignOut() { ### Redirect URLs -For _Sign in Redirect URL(s)_ inputs, you can set one URL for local development and one for production. For example: `http://localhost:3000/` in dev and `https://www.example.com/` in production. The same is true for _Sign out Redirect URL(s)_. - -If you have multiple redirect URLs, you'll need to pass them in your Amplify configuration. For example: - -```javascript -Amplify.configure({ - Auth: { - Cognito: { - loginWith: { - oauth: { - redirectSignIn: [ - 'http://localhost:3000/', - 'https://www.example.com/' - ], - redirectSignOut: [ - 'http://localhost:3000/', - 'https://www.example.com/' - ], - ...oauthConfig - } - }, - ...userPoolConfig - } - } -}); -``` +_Sign in_ & _Sign out_ redirect URL(s) are used to redirect end users after the sign in or sign out operation has occurred. You may want to specify multiple URLs for various use-cases such as having different URLs for development (`http://localhost:3000/`) production (`https://www.example.com/`) or redirect users to an intermediate URL before returning them to the app. @@ -1010,32 +944,14 @@ function App() { #### Specifying a redirect URL on sign out -If you have multiple redirect urls configured, you may choose to override the default behavior of selecting a redirect url and provide the one of your choosing when calling `signOut`. The provided redirect url should match at least one of the configured redirect urls. If no redirect url is provided to `signOut`, one will be selected based on the current app domain. +If you have multiple redirect URLs configured, you may choose to override the default behavior of selecting a redirect URL and provide the one of your choosing when calling `signOut`. The provided redirect URL should match at least one of the configured redirect URLs. If no redirect URL is provided to `signOut`, one will be selected based on the current app domain. ```ts import { Amplify } from 'aws-amplify'; import { signOut } from 'aws-amplify/auth'; -Amplify.configure({ - Auth: { - Cognito: { - loginWith: { - oauth: { - redirectSignIn: [ - 'http://localhost:3000/', - 'https://www.example.com/' - ], - redirectSignOut: [ - 'http://localhost:3000/', - 'https://www.example.com/' - ], - ...oauthConfig - } - }, - ...userPoolConfig - } - } -}); +// Assuming the following URLS were provided manually or via the Amplify configuration file, +// redirectSignOut: 'http://localhost:3000/,https://www.example.com/' signOut({ global: false,