# Anyone have a working AWS Cognito configuration w/ ouath2, openid or sso?

**URL:** https://meta.discourse.org/t/anyone-have-a-working-aws-cognito-configuration-w-ouath2-openid-or-sso/123579
**Category:** SSO
**Tags:** openid-connect
**Created:** [21 juli 2019 om 15:27 UTC](https://meta.discourse.org/t/anyone-have-a-working-aws-cognito-configuration-w-ouath2-openid-or-sso/123579 "2019-07-21T15:27:55Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![tunecrew](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tunecrew/32/195327_2.png) [@tunecrew](https://meta.discourse.org/u/tunecrew)
#### Post date: [21 juli 2019 om 15:27 UTC](https://meta.discourse.org/t/anyone-have-a-working-aws-cognito-configuration-w-ouath2-openid-or-sso/123579/1 "2019-07-21T15:27:55Z")

</div>

I’m trying to integrate Discourse with our existing Cognito UserPool.

Don’t have any IdP or SAML setup in AWS for sso so haven’t gone there.

Tried w/ openid plugin but it Discourse redirects login to the /AUTHORIZE endpoint in Cognito instead of /LOGIN - I know it gets this from the configuration in .well-known, but not sure how this is suppose to work.

Tried w/ oauth2 plugin - I see Discourse calling the /TOKEN endpoint and receiving the JWT back from Cognito, but the /USERINFO endpoint then returns an error, so it doesn’t get beyond that.

Does anyone have a working config they can share - oauth2 seems like the best route but I’m missing something somewhere apparently.

---

<div class="post-metadata">

### Author: ![Tango](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tango/32/97926_2.png) [@Tango](https://meta.discourse.org/u/Tango)
#### Post date: [5 december 2019 om 01:35 UTC](https://meta.discourse.org/t/anyone-have-a-working-aws-cognito-configuration-w-ouath2-openid-or-sso/123579/2 "2019-12-05T01:35:18Z")

</div>

How did you get on with this?

I have same need

Cheers

Todd

---

<div class="post-metadata">

### Author: ![tunecrew](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tunecrew/32/195327_2.png) [@tunecrew](https://meta.discourse.org/u/tunecrew)
#### Post date: [5 december 2019 om 15:00 UTC](https://meta.discourse.org/t/anyone-have-a-working-aws-cognito-configuration-w-ouath2-openid-or-sso/123579/3 "2019-12-05T15:00:18Z")

</div>

Hi - I have gotten any replies from anyone and I haven’t had a chance to revisit it myself unfortunately.

---

<div class="post-metadata">

### Author: ![weallwegot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/weallwegot/32/124753_2.png) [@weallwegot](https://meta.discourse.org/u/weallwegot)
#### Post date: [27 april 2021 om 04:40 UTC](https://meta.discourse.org/t/anyone-have-a-working-aws-cognito-configuration-w-ouath2-openid-or-sso/123579/4 "2021-04-27T04:40:13Z")

</div>

For AWS Cognito as an identity provider for [OpenID Connect plugin](https://meta.discourse.org/t/openid-connect-authentication-plugin/103632)

1. Click on Create a User Pool button within AWS Cognito web console
2. click on Review Defaults to use mostly the default settings  
2a. before creating the pool make sure to click on “Add an App Client”  
2b. create an App Client; give it a name and uncheck everything except `Enable refresh token based authentication (ALLOW_REFRESH_TOKEN_AUTH)`

 ![Screen Shot 2021-04-26 at 11.31.59 PM](https://global.discourse-cdn.com/meta/original/3X/7/0/708649f411b8caf628e186f4d846de256e651b40.png)  
3. Click Create pool  
4. Now under General Settings on the left menu you should click on App Client and take note of the values for **`App client id`** & **`App client secret`**  
5. Next under to App integration on the left menu you should click on Domain name. Enter a subdomain here. The name here will be the domain that users get routed here when they login.  
 ![Screen Shot 2021-04-26 at 11.36.54 PM](https://global.discourse-cdn.com/meta/original/3X/9/9/9967fdc20416e2cf10c210ceeb3425214883c3da.png)  
6. At the top left of the AWS Cognito Console - click on the Federated Identities, it’s a bit hard to find.  
 ![federated-identities](https://global.discourse-cdn.com/meta/original/3X/3/b/3bd36561091608918bbfaf7831d355f2b37c0ad8.png)  
7. Once there click on `Create new identity pool`  
8. Give the identity pool a name  
8b. Under the `Authentication providers` section use the User Pool ID from the previously created User pool & the App client id from the previously created App client.

 ![Screen Shot 2021-04-27 at 12.04.19 AM](https://global.discourse-cdn.com/meta/original/3X/b/6/b67d4f62a875b60c0e74abb07ac4fb2fafe783ff.png)  
9. Click Create Pool & Allow the console to create the IAM roles to use with the new identity pool  
10. At this point you’ve got pretty much everything you should need to get going with setting up your Discourse instance with the correct site settings. assuming you’ve installed the plugin.

**openid connect enabled:** enable this  
**openid connect client id:** use the `App Client Id` we retrieved above in the earlier steps  
**openid connect client secret:** use the `App Client Secret` we saw above in the earlier steps  
**openid connect discovery document:** the link for the discovery document URL follows the format below.. you can see the format for `userPoolId` above in the screenshot with step 8b..

```plaintext
https://cognito-idp.{region}.amazonaws.com/{userPoolId}/.well-known/openid-configuration

```

to check that you have the URL format correct - just try to paste into your browser and you should get a nice json that returns the authorization endpoint, issuer, and other things.

**openid connect authorize scope:** `openid email`

* * *

**Other things that may be useful**

- [Stackoverflow: context on the URL format for Discovery Document URL](https://stackoverflow.com/questions/47664727/can-i-use-aws-cognito-to-provide-a-open-id-connect-endpoint)
- [Stackoverflow: if you get a regex matching error when you check the discovery document URL check if you used the wrong format instead of the User Pool Id in the discovery document URL.](https://stackoverflow.com/questions/37223695/aws-cognito-error-identitypoolid-failed-to-satisfy-constraint)
- [Stackoverflow: make sure to set up the domain name or you’ll get this issue](https://stackoverflow.com/questions/50569395/aws-cognito-user-pools-and-openid)

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [25 juni 2021 om 10:53 UTC](https://meta.discourse.org/t/anyone-have-a-working-aws-cognito-configuration-w-ouath2-openid-or-sso/123579/5 "2021-06-25T10:53:41Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
