# API request to users/by-external on private forum

**URL:** <https://meta.discourse.org/t/api-request-to-users-by-external-on-private-forum/60609>\
**Category:** Development\
**Created:** [April 7, 2017, 6:40pm UTC](https://meta.discourse.org/t/api-request-to-users-by-external-on-private-forum/60609 "2017-04-07T18:40:13Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)\
**Post date:** [April 7, 2017, 6:40pm UTC](https://meta.discourse.org/t/api-request-to-users-by-external-on-private-forum/60609/1 "2017-04-07T18:40:14Z")

</div>

I’m trying to make an API GET request to `/users/by-external/:external_id.json` on a login\_required forum that is using SSO.

When the forum isn’t set to ‘login required’, the user is returned. When it is set to ‘login required’, instead of returning the user, the request is being redirected to `/session/sso`.

In the logs I’m seeing:

```plaintext
Started GET "/users/by-external/1.json" for 127.0.0.1 at 2017-04-07 10:46:55 -0700
Processing by UsersController#show as */*
Parameters: {"external_id"=>"1.json", "user"=>{}}
UserField Load (2.6ms) SELECT "user_fields".* FROM "user_fields"
Redirected to http://localhost:3000/session/sso
Filter chain halted as :redirect_to_login_if_required rendered or redirected

```

The problem seems to be happening in `ApplicationController#redirect_to_login_if_required`  
[discourse/app/controllers/application\_controller.rb at main · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/master/app/controllers/application_controller.rb#L523)

When I check the values for `request.format.json?` and `is_api?` inside of the `redirect_to_login_if_required` method they are both returning false.

Is there any way to get this to work?

---

_[View the full topic](https://meta.discourse.org/t/api-request-to-users-by-external-on-private-forum/60609)._
