Skip to content

Commit badfebd

Browse files
committed
Revert "separate web and mobile examples for redirect uri's"
This reverts commit e6fad5d.
1 parent e6fad5d commit badfebd

File tree

1 file changed

+4
-155
lines changed
  • src/pages/[platform]/build-a-backend/auth/concepts/external-identity-providers

1 file changed

+4
-155
lines changed

src/pages/[platform]/build-a-backend/auth/concepts/external-identity-providers/index.mdx

Lines changed: 4 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ Secrets must be created manually with [`ampx sandbox secret`](/[platform]/refere
116116

117117
</Callout>
118118

119-
<InlineFilter filters={["angular", "javascript", "nextjs", "react", "react-native", "vue"]}>
120-
121119
```ts title="amplify/auth/resource.ts"
122120
import { defineAuth, secret } from '@aws-amplify/backend';
123121

@@ -152,42 +150,6 @@ export const auth = defineAuth({
152150
});
153151
```
154152

155-
</InlineFilter>
156-
<InlineFilter filters={["android", "flutter", "swift"]}>
157-
158-
```ts title="amplify/auth/resource.ts"
159-
import { defineAuth, secret } from '@aws-amplify/backend';
160-
161-
export const auth = defineAuth({
162-
loginWith: {
163-
externalProviders: {
164-
google: {
165-
clientId: secret('GOOGLE_CLIENT_ID'),
166-
clientSecret: secret('GOOGLE_CLIENT_SECRET')
167-
},
168-
signInWithApple: {
169-
clientId: secret('SIWA_CLIENT_ID'),
170-
keyId: secret('SIWA_KEY_ID'),
171-
privateKey: secret('SIWA_PRIVATE_KEY'),
172-
teamId: secret('SIWA_TEAM_ID')
173-
},
174-
loginWithAmazon: {
175-
clientId: secret('LOGINWITHAMAZON_CLIENT_ID'),
176-
clientSecret: secret('LOGINWITHAMAZON_CLIENT_SECRET')
177-
},
178-
facebook: {
179-
clientId: secret('FACEBOOK_CLIENT_ID'),
180-
clientSecret: secret('FACEBOOK_CLIENT_SECRET')
181-
},
182-
callbackUrls: ['myapp://'],
183-
logoutUrls: ['myapp://'],
184-
}
185-
}
186-
});
187-
```
188-
189-
</InlineFilter>
190-
191153
You need to now inform your external provider of the newly configured authentication resource and its OAuth redirect URI:
192154

193155
<BlockSwitcher>
@@ -258,8 +220,6 @@ You need to now inform your external provider of the newly configured authentica
258220

259221
You can determine the pieces of data you want to retrieve from each external provider when setting them up in the `amplify/auth/resource.ts` file using `scopes`.
260222

261-
<InlineFilter filters={["angular", "javascript", "nextjs", "react", "react-native", "vue"]}>
262-
263223
```ts title="amplify/auth/resource.ts"
264224
import { defineAuth } from '@aws-amplify/backend';
265225

@@ -282,30 +242,6 @@ export const auth = defineAuth({
282242
});
283243
```
284244

285-
</InlineFilter>
286-
<InlineFilter filters={["android", "flutter", "swift"]}>
287-
288-
```ts title="amplify/auth/resource.ts"
289-
import { defineAuth } from '@aws-amplify/backend';
290-
291-
export const auth = defineAuth({
292-
loginWith: {
293-
externalProviders: {
294-
loginWithAmazon: {
295-
clientId: secret('LOGINWITHAMAZON_CLIENT_ID'),
296-
clientSecret: secret('LOGINWITHAMAZON_CLIENT_SECRET'),
297-
// highlight-next-line
298-
scopes: ['email']
299-
},
300-
callbackUrls: ['myapp://'],
301-
logoutUrls: ['myapp://'],
302-
}
303-
}
304-
});
305-
```
306-
307-
</InlineFilter>
308-
309245
### Attribute mapping
310246

311247
You can map which attributes are mapped between your external identity provider and your users created in Cognito. We will be able to have the best level of protection for developers if we ensure that attribute mappings that would not work are called out by the type system.
@@ -316,8 +252,6 @@ If you specify an attribute in your authentication resource as required, and it
316252

317253
</Callout>
318254

319-
<InlineFilter filters={["angular", "javascript", "nextjs", "react", "react-native", "vue"]}>
320-
321255
```ts title="amplify/auth/resource.ts"
322256
import { defineAuth } from '@aws-amplify/backend';
323257

@@ -342,35 +276,6 @@ export const auth = defineAuth({
342276
}
343277
});
344278
```
345-
346-
</InlineFilter>
347-
<InlineFilter filters={["android", "flutter", "swift"]}>
348-
349-
```ts title="amplify/auth/resource.ts"
350-
import { defineAuth } from '@aws-amplify/backend';
351-
352-
export const auth = defineAuth({
353-
loginWith: {
354-
externalAuthProviders: {
355-
loginWithAmazon: {
356-
clientId: secret('LOGINWITHAMAZON_CLIENT_ID'),
357-
clientSecret: secret('LOGINWITHAMAZON_CLIENT_SECRET'),
358-
// highlight-start
359-
attributeMapping: {
360-
email: 'email'
361-
}
362-
// highlight-end
363-
},
364-
callbackUrls: ['myapp://'],
365-
logoutUrls: ['myapp://'],
366-
}
367-
}
368-
});
369-
```
370-
371-
</InlineFilter>
372-
373-
374279
<InlineFilter filters={["angular", "javascript", "nextjs", "react", "vue"]}>
375280
- [Learn more about configuring the React Authenticator component for external providers](https://ui.docs.amplify.aws/react/connected-components/authenticator/configuration#external-providers)
376281
</InlineFilter>
@@ -379,8 +284,6 @@ export const auth = defineAuth({
379284

380285
To setup a OIDC provider, you can configure them in your `amplify/auth/resource.ts` file. For example, if you would like to setup a Microsoft EntraID provider, you can do so as follows:
381286

382-
<InlineFilter filters={["angular", "javascript", "nextjs", "react", "react-native", "vue"]}>
383-
384287
```ts title="amplify/auth/resource.ts"
385288
import { defineAuth, secret } from '@aws-amplify/backend';
386289

@@ -406,34 +309,6 @@ export const auth = defineAuth({
406309
});
407310
```
408311

409-
</InlineFilter>
410-
<InlineFilter filters={["android", "flutter", "swift"]}>
411-
412-
```ts title="amplify/auth/resource.ts"
413-
import { defineAuth, secret } from '@aws-amplify/backend';
414-
415-
export const auth = defineAuth({
416-
loginWith: {
417-
email: true,
418-
externalProviders: {
419-
oidc: [
420-
{
421-
name: 'MicrosoftEntraID',
422-
clientId: secret('MICROSOFT_ENTRA_ID_CLIENT_ID'),
423-
clientSecret: secret('MICROSOFT_ENTRA_ID_CLIENT_SECRET'),
424-
issuerUrl: '<your-issuer-url>',
425-
},
426-
],
427-
callbackUrls: ['myapp://'],
428-
logoutUrls: ['myapp://'],
429-
},
430-
},
431-
});
432-
```
433-
434-
</InlineFilter>
435-
436-
437312
<InlineFilter filters={["angular", "javascript", "nextjs", "react", "vue"]}>
438313

439314
Use the `signInWithRedirect` API to initiate sign-in with an OIDC identity provider.
@@ -453,8 +328,6 @@ await signInWithRedirect({
453328

454329
To setup a SAML provider, you can configure them in your `amplify/auth/resource.ts` file. For example, if you would like to setup a Microsoft EntraID provider, you can do so as follows:
455330

456-
<InlineFilter filters={["angular", "javascript", "nextjs", "react", "react-native", "vue"]}>
457-
458331
```ts title="amplify/auth/resource.ts"
459332
import { defineAuth } from '@aws-amplify/backend';
460333

@@ -479,33 +352,6 @@ export const auth = defineAuth({
479352
});
480353
```
481354

482-
</InlineFilter>
483-
<InlineFilter filters={["android", "flutter", "swift"]}>
484-
485-
```ts title="amplify/auth/resource.ts"
486-
import { defineAuth } from '@aws-amplify/backend';
487-
488-
export const auth = defineAuth({
489-
loginWith: {
490-
email: true,
491-
externalProviders: {
492-
saml: {
493-
name: 'MicrosoftEntraIDSAML',
494-
metadata: {
495-
metadataContent: '<your-url-hosting-saml-metadata>', // or content of the metadata file
496-
metadataType: 'URL', // or 'FILE'
497-
},
498-
},
499-
callbackUrls: ['myapp://'],
500-
logoutUrls: ['myapp://'],
501-
},
502-
},
503-
});
504-
```
505-
506-
</InlineFilter>
507-
508-
509355
<InlineFilter filters={["angular", "javascript", "nextjs", "react", "vue"]}>
510356

511357
Use the `signInWithRedirect` API to initiate sign-in with a SAML identity provider.
@@ -626,6 +472,7 @@ import { signInWithRedirect } from 'aws-amplify/auth';
626472
signInWithRedirect({
627473
provider: 'Apple'
628474
});
475+
629476
```
630477

631478
### Redirect URLs
@@ -636,6 +483,7 @@ _Sign in_ & _Sign out_ redirect URL(s) are used to redirect end users after the
636483
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.
637484

638485
```ts
486+
import { Amplify } from 'aws-amplify';
639487
import { signOut } from 'aws-amplify/auth';
640488

641489
// Assuming the following URLS were provided manually or via the Amplify configuration file,
@@ -644,9 +492,10 @@ import { signOut } from 'aws-amplify/auth';
644492
signOut({
645493
global: false,
646494
oauth: {
647-
redirectUrl: 'https://authProvider/logout?logout_uri=myapp://'
495+
redirectUrl: 'https://authProvider/logout?logout_uri=myDevApp://'
648496
}
649497
});
498+
650499
```
651500
<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>
652501

0 commit comments

Comments
 (0)