-
Notifications
You must be signed in to change notification settings - Fork 1.1k
chore: add information about the new signOut redirect url option #7938
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2d8df41
313130c
f5bcc08
772acce
188d514
f644e2e
5014e27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sanity check: Gen2 doc doesn't have an equivalent page for adding this information? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I couldn't find any relevant place. Only relatable location is the signOut page but that's for the common use-case and Gen2 has nothing on signInWithRedirect I believe. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added it here for Gen2. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -739,40 +739,40 @@ function App() { | |
</Block> | ||
</BlockSwitcher> | ||
|
||
</InlineFilter> | ||
### Redirect URLs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this section is redundant. By examining lines There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On RN page, we don't have any info on redirects so I thought this will set up some context before diving into multiple redirects. |
||
|
||
<InlineFilter filters={["javascript", "angular", "nextjs", "react", "vue"]}> | ||
_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. | ||
|
||
### Redirect URLs | ||
#### Specifying a redirect URL on sign out | ||
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. | ||
|
||
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)_. | ||
```ts | ||
israx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import { Amplify } from 'aws-amplify'; | ||
import { signOut } from 'aws-amplify/auth'; | ||
|
||
If you have multiple redirect URI inputs, you'll need to pass them in your Amplify configuration. For example: | ||
// Assuming the following URLS were provided manually or via the Amplify configuration file, | ||
// redirectSignOut: 'myDevApp://,https://authProvider/logout/?logout_uri=myDevApp://' | ||
|
||
```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 | ||
} | ||
signOut({ | ||
global: false, | ||
oauth: { | ||
redirectUrl: 'https://authProvider/logout/?logout_uri=myDevApp://' | ||
} | ||
}); | ||
|
||
|
||
``` | ||
<Callout> 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. </Callout> | ||
|
||
</InlineFilter> | ||
|
||
<InlineFilter filters={["javascript", "angular", "nextjs", "react", "vue"]}> | ||
|
||
### Redirect URLs | ||
|
||
<Accordion title='Full Example using multiple redirect URIs' headingLevel='4' eyebrow='Example'> | ||
_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. | ||
|
||
<Accordion title='Full Example using multiple redirect URLs' headingLevel='4' eyebrow='Example'> | ||
|
||
<BlockSwitcher> | ||
<Block name="TypeScript"> | ||
|
@@ -943,6 +943,25 @@ function App() { | |
|
||
</Accordion> | ||
|
||
#### 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 | ||
import { Amplify } from 'aws-amplify'; | ||
import { signOut } from 'aws-amplify/auth'; | ||
|
||
// Assuming the following URLS were provided manually or via the Amplify configuration file, | ||
// redirectSignOut: 'http://localhost:3000/,https://www.example.com/' | ||
|
||
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: | ||
|
Uh oh!
There was an error while loading. Please reload this page.