Skip to content

mv mobile auth sign-in content to "connect your frontend", add advanced workflows #7456

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions src/directory/directory.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ export const directory = {
{
path: 'src/pages/[platform]/build-a-backend/auth/connect-your-frontend/sign-in/index.mdx'
},
{
path: 'src/pages/[platform]/build-a-backend/auth/connect-your-frontend/sign-in-with-web-ui/index.mdx'
},
{
path: 'src/pages/[platform]/build-a-backend/auth/connect-your-frontend/switching-authentication-flows/index.mdx'
},
Expand All @@ -111,6 +114,9 @@ export const directory = {
{
path: 'src/pages/[platform]/build-a-backend/auth/connect-your-frontend/manage-user-attributes/index.mdx'
},
{
path: 'src/pages/[platform]/build-a-backend/auth/connect-your-frontend/multi-step-sign-in/index.mdx'
},
{
path: 'src/pages/[platform]/build-a-backend/auth/connect-your-frontend/listen-to-auth-events/index.mdx'
},
Expand Down Expand Up @@ -147,18 +153,23 @@ export const directory = {
}
]
},
{
path: 'src/pages/[platform]/build-a-backend/auth/multi-step-sign-in/index.mdx'
},
{
path: 'src/pages/[platform]/build-a-backend/auth/sign-in-with-web-ui/index.mdx'
},
{
path: 'src/pages/[platform]/build-a-backend/auth/app-uninstall/index.mdx'
},
{
path: 'src/pages/[platform]/build-a-backend/auth/data-usage-policy/index.mdx'
},
{
path: 'src/pages/[platform]/build-a-backend/auth/advanced-workflows/index.mdx',
children: [
{
path: 'src/pages/[platform]/build-a-backend/auth/advanced-workflows/federation-only/index.mdx'
},
{
path: 'src/pages/[platform]/build-a-backend/auth/advanced-workflows/custom-token-provider/index.mdx'
}
]
},
{
path: 'src/pages/[platform]/build-a-backend/auth/grant-access-to-auth-resources/index.mdx'
},
Expand All @@ -168,9 +179,6 @@ export const directory = {
{
path: 'src/pages/[platform]/build-a-backend/auth/moving-to-production/index.mdx'
},
{
path: 'src/pages/[platform]/build-a-backend/auth/advanced-workflows/index.mdx'
},
{
path: 'src/pages/[platform]/build-a-backend/auth/use-aws-sdk/index.mdx'
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { getCustomStaticPath } from '@/utils/getCustomStaticPath';

export const meta = {
title: 'Custom token provider',
description: 'Learn how to configure Amplify client libraries to interact with and use a custom token provider',
platforms: [
// 'android',
'angular',
// 'flutter',
'javascript',
'nextjs',
'react',
'react-native',
// 'swift',
'vue'
]
};

export function getStaticPaths() {
return getCustomStaticPath(meta.platforms);
}

export function getStaticProps() {
return {
props: {
meta
}
};
}

Amplify client libraries can be configured to fetch access tokens and ID tokens from an OpenID Connect (OIDC) compliant identity provider (IdP) in place of Amazon Cognito. This is useful if you intend to keep user profile data in your existing identity provider and reduce costs by configuring Amplify resources such as Amplify Data to use an OIDC provider directly.

```ts title="src/main.ts"
import { Amplify } from 'aws-amplify';
import { TokenProvider, decodeJWT } from 'aws-amplify/auth';
import outputs from '../amplify_outputs.json'

// ...

const myTokenProvider: TokenProvider = {
async getTokens({ forceRefresh } = {}) {
if (forceRefresh) {
// try to obtain new tokens if possible
}

const accessTokenString = '<access-token-from-provider>';
const idTokenString = '<id-token-from-provider>';

return {
accessToken: decodeJWT(accessTokenString),
idToken: decodeJWT(idTokenString),
};
},
};

Amplify.configure(outputs, {
Auth: {
tokenProvider: myTokenProvider
}
});
```

## Next steps

- [Learn more about tokens and credentials in Amplify](/[platform]/build-a-backend/auth/concepts/tokens-and-credentials/)
- [Learn how to federate with an Amazon Cognito Identity Pool to obtain AWS credentials for service interactions](/[platform]/build-a-backend/auth/advanced-workflows/federation-only/)
Loading
Loading