# Oauth Redirecting to /login after successful user JSON call

**URL:** https://meta.discourse.org/t/oauth-redirecting-to-login-after-successful-user-json-call/143851
**Category:** SSO
**Tags:** oauth2
**Created:** [10 במרץ,‏ 2020,‏ 10:52pm UTC](https://meta.discourse.org/t/oauth-redirecting-to-login-after-successful-user-json-call/143851 "2020-03-10T22:52:22Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![patrickeaton](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@patrickeaton](https://meta.discourse.org/u/patrickeaton)
#### Post date: [10 במרץ,‏ 2020,‏ 10:52pm UTC](https://meta.discourse.org/t/oauth-redirecting-to-login-after-successful-user-json-call/143851/1 "2020-03-10T22:52:22Z")

</div>

My configuration for Oauth basic is behaving quite odd, I had a few errors initially during setup and have resolved them. However, now I can see the flow going from Discourse → Cognito Authorize Endpoint → Discourse Callback → Discourse /login. There is no warning or errors in the log, and when checking the logs, I can see that there is a successful JSON call to grab the user data.

Given that it appears to have a successful token and has loaded the JSON data, I would expect the user account to be successfully registered, instead the user is redirected to the login page.

Please see logs below.

```
OAuth2 Debugging: after_authenticate response: creds: {"token"=>"eyJraWQiOiJ3YW8zbVBRWmh2Z2F6YldNaU5jS3ZOdVdRMXRmcm1ya2ZVZ2RvVjVYSG1RPSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiJkNzhkZDliNS03Mjc2LTQ5OWEtYjdiN
3:48 pm
OAuth2 Debugging: user_json_url: GET https://api.lifebac.com/token/details?token=eyJraWQiOiJ3YW8zbVBRWmh2Z2F6YldNaU5jS3ZOdVdRMXRmcm1ya2ZVZ2RvVjVYSG1RPSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiJkNzhkZDliNS03Mjc
3:48 pm
OAuth2 Debugging: user_json_response: #<Excon::Response:0x00007f36a7608a30 @data={:body=>"{\"id\":\"d78dd9b5-7276-499a-b7b6-02da38e03ce9\", ...}", :cookies=>[], :host=>"api.lifebac.com", :headers=>{"Conten
3:48 pm
OAuth2 Debugging: user_json: {"id"=>"d78dd9b5-7276-499a-b7b6-02da38e03ce9", ...}

```

Any help on what is occurring would be incredibly helpful. More than happy to supply the backtraces if needed.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [11 במרץ,‏ 2020,‏ 4:15pm UTC](https://meta.discourse.org/t/oauth-redirecting-to-login-after-successful-user-json-call/143851/2 "2020-03-11T16:15:40Z")

</div>

> [@patrickeaton](#):
>
> redirected to the login page

The redirection is normal, but there should also be a registration popup. Are you seeing that?

The user account is only created after the user confirms the account details and presses create.

---

<div class="post-metadata">

### Author: ![patrickeaton](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@patrickeaton](https://meta.discourse.org/u/patrickeaton)
#### Post date: [11 במרץ,‏ 2020,‏ 4:23pm UTC](https://meta.discourse.org/t/oauth-redirecting-to-login-after-successful-user-json-call/143851/3 "2020-03-11T16:23:38Z")

</div>

Hi David,

Unfortunately, that information is coming up blank with nothing to confirm without entering it all their information.

Also, is it possible to auto-confirm the user? Their email is already verified on our side and I’d like to keep this experience as seamless as possible for our users?

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [11 במרץ,‏ 2020,‏ 4:34pm UTC](https://meta.discourse.org/t/oauth-redirecting-to-login-after-successful-user-json-call/143851/4 "2020-03-11T16:34:43Z")

</div>

It’s not possible to skip the popup (yet), but it should all be automatically populated with data from your identity provider.

What are the values for your oauth2 settings? Let’s take `oauth2_json_email_path` as an example.

Also, can you share the complete “user\_json” line from the log, so we can see all the keys. (feel free to scrub the emails)

---

<div class="post-metadata">

### Author: ![patrickeaton](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@patrickeaton](https://meta.discourse.org/u/patrickeaton)
#### Post date: [11 במרץ,‏ 2020,‏ 4:50pm UTC](https://meta.discourse.org/t/oauth-redirecting-to-login-after-successful-user-json-call/143851/5 "2020-03-11T16:50:35Z")

</div>

The full data was

`{"id"=>"d78dd9b5-7276-499a-b7b6-02da38e03ce9", "username"=>"patrick2"}`

and the field values were “id” and “username” for the applicable fields.

I’m currently updating the endpoint to add email and name, but I was under the impression that only a id and username were required.

Thanks

Patrick

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [11 במרץ,‏ 2020,‏ 4:53pm UTC](https://meta.discourse.org/t/oauth-redirecting-to-login-after-successful-user-json-call/143851/6 "2020-03-11T16:53:32Z")

</div>

The minimum data to **connect** the account to a Discourse account is just the `id`. However, Discourse needs a username and email. That’s why we pop the sign-up modal.

If you can add that information to the OAuth API then that would make things much smoother for your users 👍

---

<div class="post-metadata">

### Author: ![patrickeaton](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@patrickeaton](https://meta.discourse.org/u/patrickeaton)
#### Post date: [11 במרץ,‏ 2020,‏ 4:55pm UTC](https://meta.discourse.org/t/oauth-redirecting-to-login-after-successful-user-json-call/143851/7 "2020-03-11T16:55:58Z")

</div>

Yep, on that one right now! Will update the endpoint to include email as well and see if that resolves this.

Though in that case, surely the username should at least be coming through to the signup page?

Thanks

Patrick

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [11 במרץ,‏ 2020,‏ 4:56pm UTC](https://meta.discourse.org/t/oauth-redirecting-to-login-after-successful-user-json-call/143851/8 "2020-03-11T16:56:31Z")

</div>

> [@patrickeaton](#):
>
> Though in that case, surely the username should at least be coming through to the signup page?

Yes it should. Have you configured `oauth2_json_username_path` to be `username`?

---

<div class="post-metadata">

### Author: ![patrickeaton](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@patrickeaton](https://meta.discourse.org/u/patrickeaton)
#### Post date: [11 במרץ,‏ 2020,‏ 4:57pm UTC](https://meta.discourse.org/t/oauth-redirecting-to-login-after-successful-user-json-call/143851/9 "2020-03-11T16:57:29Z")

</div>

![image](https://global.discourse-cdn.com/meta/original/3X/8/c/8cad41670deed000907185150cac2241778da84b.png)

---

<div class="post-metadata">

### Author: ![patrickeaton](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@patrickeaton](https://meta.discourse.org/u/patrickeaton)
#### Post date: [11 במרץ,‏ 2020,‏ 7:17pm UTC](https://meta.discourse.org/t/oauth-redirecting-to-login-after-successful-user-json-call/143851/10 "2020-03-11T19:17:51Z")

</div>

@david, cheers mate! Got that one all working with the data.

What is the correct way to request a flag to auto-confirm oauth users?

Thanks

Patrick

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [11 במרץ,‏ 2020,‏ 10:24pm UTC](https://meta.discourse.org/t/oauth-redirecting-to-login-after-successful-user-json-call/143851/11 "2020-03-11T22:24:58Z")

</div>

> [@patrickeaton](#):
>
> request a flag to auto-confirm oauth users?

What do you mean by auto-confirm? Skip email confirmation? Or skip the registration modal?

The first can be done already. The second is on our radar to implement soon.

---

<div class="post-metadata">

### Author: ![patrickeaton](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@patrickeaton](https://meta.discourse.org/u/patrickeaton)
#### Post date: [11 במרץ,‏ 2020,‏ 10:26pm UTC](https://meta.discourse.org/t/oauth-redirecting-to-login-after-successful-user-json-call/143851/12 "2020-03-11T22:26:31Z")

</div>

Perfect! I meant the second! But if it’s already on your radar, then we’re all good!

---

<div class="post-metadata">

### Author: ![rishabh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rishabh/32/179446_2.png) [@rishabh](https://meta.discourse.org/u/rishabh)
#### Post date: [10 ביולי,‏ 2020,‏ 6:59am UTC](https://meta.discourse.org/t/oauth-redirecting-to-login-after-successful-user-json-call/143851/13 "2020-07-10T06:59:57Z")

</div>

Is the new `external_auth_skip_create_confirm` setting from [Automatically provision accounts with external SSO provider? (skip Create New Account prompt) - #6 by david](https://meta.discourse.org/t/automatically-provision-accounts-with-external-sso-provider-skip-create-new-account-prompt/134511/6) supported on  
Oauth2?

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [10 ביולי,‏ 2020,‏ 8:19am UTC](https://meta.discourse.org/t/oauth-redirecting-to-login-after-successful-user-json-call/143851/14 "2020-07-10T08:19:38Z")

</div>

It sure is! It’s supported on every single Discourse auth provider (even Facebook, Github, Google, etc.) 😃
