|
| 1 | +--- |
| 2 | +id: amazon |
| 3 | +title: Add Amazon as a social sign-in provider in Ory |
| 4 | +sidebar_label: Amazon |
| 5 | +--- |
| 6 | + |
| 7 | +# Amazon |
| 8 | + |
| 9 | +:::note |
| 10 | + |
| 11 | +To add Amazon as a social sign-in provider, you need a Amazon Developer account. Go to |
| 12 | +[Amazon Developers](https://developer.amazon.com/) to create one. |
| 13 | + |
| 14 | +::: |
| 15 | + |
| 16 | +````mdx-code-block |
| 17 | +import Tabs from '@theme/Tabs'; |
| 18 | +import TabItem from '@theme/TabItem'; |
| 19 | +
|
| 20 | +<Tabs> |
| 21 | +<TabItem value="console" label="Ory Console" default> |
| 22 | +
|
| 23 | +Follow these steps to add Amazon as a social sign-in provider for your project, using the Ory Console. |
| 24 | +
|
| 25 | +1. Go to <ConsoleLink route="project.socialSignIn" />. |
| 26 | +1. Enable the **Enable OpenID Connect** toggle, then click **Add new OpenID Connect provider**. |
| 27 | +1. Click the Amazon logo to open the **Configure Amazon** screen. You may need to click **Show more providers** to see the full list of providers. |
| 28 | +1. Copy the Redirect URI and save it for later use. |
| 29 | +1. Follow the [official steps](https://developer.amazon.com/docs/login-with-amazon/register-web.html) to create a security profile. |
| 30 | +1. Once you've created the security profile, click **Show Client Secret** and copy the Client ID and Client secret. Then paste them into the corresponding fields in the Ory Console's **Configure Amazon** screen. |
| 31 | +1. In the Ory Console, click **Save Configuration** to enable Amazon as a social sign-in provider. |
| 32 | +1. On Amazon Developers, click **Save Changes**. |
| 33 | +1. Open the Amazon **Security Profile Management** screen, select the **Web Settings** tab, click **Edit**, and paste the redirect URI into the **Allowed Return URLs** field. Click **Save**. |
| 34 | +
|
| 35 | +:::note |
| 36 | +
|
| 37 | +These steps cover the basic configuration of a social sign-in provider integration. At this point, the user experience is |
| 38 | +incomplete. To complete the configuration and ensure a smooth and secure user experience, configure the [scopes](#scopes) and |
| 39 | +[data mapping](#data-mapping) as described in the next section. |
| 40 | +
|
| 41 | +::: |
| 42 | +
|
| 43 | +## Additional configuration |
| 44 | +
|
| 45 | +When adding a social sign-in provider, you can customize the integration by defining the OAuth scopes Ory requests from the |
| 46 | +provider and by setting up custom data mappings. |
| 47 | +
|
| 48 | +### Scopes |
| 49 | +
|
| 50 | +In the **Scopes** field, you can define the OAuth (access) scopes that Ory requests from the sign-in provider. Defining access scopes enables you to |
| 51 | +interact with the provider's APIs on behalf of the user, or to access additional user data, which is exposed as claims for data |
| 52 | +mapping. |
| 53 | +
|
| 54 | +For a basic setup, follow these steps to add the profile access scope: |
| 55 | +
|
| 56 | +- In Ory Console's **Configure Amazon** screen, click **Show advanced settings**. |
| 57 | +- In the **Scopes** field, enter `profile` and click **Add**. |
| 58 | +
|
| 59 | +To learn more about the scopes available for Amazon, read the |
| 60 | +[related documentation](https://developer.amazon.com/docs/login-with-amazon/customer-profile.html). |
| 61 | +
|
| 62 | +### Data mapping |
| 63 | +
|
| 64 | +In the **Data mapping** field, you can map the data returned by the sign-in provider to traits as defined in the identity |
| 65 | +schema. |
| 66 | +
|
| 67 | +To define the mapping, create a Jsonnet code snippet. Read [this document](./data-mapping) to learn more about Jsonnet data |
| 68 | +mapping. |
| 69 | +
|
| 70 | +In this sample Jsonnet snippet, the user's `email`, is mapped to `email` in the identity schema. |
| 71 | +
|
| 72 | +```jsonnet |
| 73 | +local claims = std.extVar('claims'); |
| 74 | +{ |
| 75 | + identity: { |
| 76 | + traits: { |
| 77 | + // The email might be empty if the user hasn't granted permissions for the email scope. |
| 78 | + [if 'email' in claims then 'email' else null]: claims.email, |
| 79 | + }, |
| 80 | + }, |
| 81 | +} |
| 82 | +``` |
| 83 | +
|
| 84 | +
|
| 85 | +</TabItem> |
| 86 | +<TabItem value="cli" label="Ory CLI"> |
| 87 | +Follow these steps to add Amazon as a social sign-in provider to your project using the Ory CLI: |
| 88 | +3. Encode the Jsonnet snippet with [Base64](https://www.base64encode.org/) or host it under an URL accessible to Ory Network. |
| 89 | +
|
| 90 | + ```shell |
| 91 | + cat your-data-mapping.jsonnet | base64 |
| 92 | + ``` |
| 93 | +
|
| 94 | +4. Download the Ory Identities config from your project and save it to a file: |
| 95 | +
|
| 96 | + ```shell |
| 97 | + ## List all available workspaces |
| 98 | + ory list workspaces |
| 99 | +
|
| 100 | + ## List all available projects |
| 101 | + ory list projects --workspace <workspace-id> |
| 102 | +
|
| 103 | + ## Get config |
| 104 | + ory get identity-config --project <project-id> --workspace <workspace-id> --format yaml > identity-config.yaml |
| 105 | + ``` |
| 106 | +
|
| 107 | +5. Add the social sign-in provider configuration to the downloaded config. Add the Jsonnet snippet with mappings as a Base64 |
| 108 | + string or provide an URL to the file. |
| 109 | +
|
| 110 | + ```yaml |
| 111 | + selfservice: |
| 112 | + methods: |
| 113 | + oidc: |
| 114 | + config: |
| 115 | + providers: |
| 116 | + - id: amazon # this is `<provider-id>` in the Authorization callback URL. DO NOT CHANGE IT ONCE SET! |
| 117 | + provider: amazon |
| 118 | + client_id: .... # Replace this with the OAuth2 Client ID provided by Amazon app |
| 119 | + client_secret: .... # Replace this with the OAuth2 Client Secret provided by Amazon app |
| 120 | + mapper_url: "base64://{YOUR_BASE64_ENCODED_JSONNET_HERE}" |
| 121 | + # Alternatively, use an URL like this example |
| 122 | + # mapper_url: https://storage.googleapis.com/example-example-prd/example-file |
| 123 | + scope: |
| 124 | + - profile |
| 125 | + pkce: "force" |
| 126 | + enabled: true |
| 127 | + ``` |
| 128 | +
|
| 129 | +6. Update the Ory Identities configuration using the file you worked with: |
| 130 | +
|
| 131 | + ```shell |
| 132 | + ory update identity-config --project <project-id> --workspace <workspace-id> --file identity-config.yaml |
| 133 | + ``` |
| 134 | +
|
| 135 | +</TabItem> |
| 136 | +</Tabs> |
| 137 | +```` |
| 138 | + |
| 139 | +## Troubleshooting |
| 140 | + |
| 141 | +```mdx-code-block |
| 142 | +import SocialSigninTroubleshooting from '../_common/social-sign-in-troubleshooting.mdx' |
| 143 | +
|
| 144 | +<SocialSigninTroubleshooting /> |
| 145 | +``` |
0 commit comments