Skip to content

Commit ca1e52a

Browse files
authored
Merge pull request #192 from FormidableLabs/docs-for-amazoncognito
Add docs for AWS cognito
2 parents a1c713e + 5aab32c commit ca1e52a

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ These providers are OpenID compliant, which means you can use [autodiscovery](ht
3131
* [Okta](https://developer.okta.com) ([Example configuration](#okta))
3232
* [Keycloak](http://www.keycloak.org/) ([Example configuration](#keycloak))
3333
* [Azure Active Directory](https://docs.microsoft.com/en-us/azure/active-directory) ([Example configuration](#azure-active-directory))
34+
* [AWS Cognito](https://eu-west-1.console.aws.amazon.com/cognito) ([Example configuration](#aws-cognito))
3435

3536
### Tested OAuth2 providers:
3637

@@ -673,6 +674,44 @@ await revoke(config, {
673674
});
674675
```
675676

677+
### AWS Cognito
678+
679+
First, set up a your user pool in [the AWS console](https://eu-west-1.console.aws.amazon.com/cognito). In the details of your new user pool, go down to `App clients` to create a new client. Make sure you create a client **without** a client secret (it's redundant on mobile). You should get an alphanumeric string which is your `<CLIENT_ID>`.
680+
681+
Now you need to set up your domain name. This will be on the left menu in your pool details page, under App Integration -> Domain Name. What this is depends on your preference. E.g. for AppAuth demo, mine is `https://app-auth-test.auth.eu-west-1.amazoncognito.com` as I chose `app-auth-test` as the domain and `eu-west-1` as the region.
682+
683+
Finally, you need to configure your app client. Go to App Integration -> App Client Settings.
684+
1. Enable your newly created user pool under Enabled Identity Providers.
685+
2. Add the callback url (must be same as in your config, e.g. `com.myclientapp://myclient/redirect`)
686+
3. Enable the Authorization code grant
687+
4. Enable openid scope
688+
689+
690+
```js
691+
const config = {
692+
clientId: '<YOUR_CLIENT_ID>',
693+
redirectUrl: 'com.myclientapp://myclient/redirect',
694+
serviceConfiguration: {
695+
authorizationEndpoint: '<YOUR_DOMAIN_NAME>/oauth2/authorize',
696+
tokenEndpoint: '<YOUR_DOMAIN_NAME>/oauth2/token',
697+
revocationEndpoint: '<YOUR_DOMAIN_NAME>/oauth2/revoke'
698+
}
699+
};
700+
701+
// Log in to get an authentication token
702+
const authState = await authorize(config);
703+
704+
// Refresh token
705+
const refreshedState = await refresh(config, {
706+
refreshToken: authState.refreshToken,
707+
});
708+
709+
// Revoke token
710+
await revoke(config, {
711+
tokenToRevoke: refreshedState.refreshToken
712+
});
713+
```
714+
676715
## Contributors
677716

678717
Thanks goes to these wonderful people

0 commit comments

Comments
 (0)