# Using node.js (discourse-sdk) API when SSO is enabled?

**URL:** https://meta.discourse.org/t/using-node-js-discourse-sdk-api-when-sso-is-enabled/203378
**Category:** Support
**Created:** [September 13, 2021, 10:46am UTC](https://meta.discourse.org/t/using-node-js-discourse-sdk-api-when-sso-is-enabled/203378 "2021-09-13T10:46:46Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ChrisBeach](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chrisbeach/32/214628_2.png) [@ChrisBeach](https://meta.discourse.org/u/ChrisBeach)
#### Post date: [September 13, 2021, 10:46am UTC](https://meta.discourse.org/t/using-node-js-discourse-sdk-api-when-sso-is-enabled/203378/1 "2021-09-13T10:46:46Z")

</div>

I’m using the node.js API client ([GitHub - 99x/discourse-sdk: Node SDK for discourse forum software · GitHub](https://github.com/99x/discourse-sdk)) for a simple integration with my forum.

I immediately ran into problems as my forum is configured for [Discourse SSO](https://meta.discourse.org/t/13045?silent=true) (AKA [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true)). When making API requests I got an error as the API consumer was not “logged in” to my SSO provider website.

As an experiment, I modified the discourse-sdk node.js API client so its requests included the cookies expected by my SSO provider website. This got me a little further.

However, my node.js code gets a payload containing an HTML rendering of the Discourse forum and not the data (in json form) that I expected.

I think I might be taking the wrong approach here. Is there a way for me to bypass [Discourse SSO](https://meta.discourse.org/t/13045?silent=true) when using the API (i.e. a query string param, a different API endpoint, or a Discourse settings change, perhaps)

I’d appreciate your help.

Thanks

---

<div class="post-metadata">

### Author: ![ChrisBeach](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chrisbeach/32/214628_2.png) [@ChrisBeach](https://meta.discourse.org/u/ChrisBeach)
#### Post date: [September 13, 2021, 10:56am UTC](https://meta.discourse.org/t/using-node-js-discourse-sdk-api-when-sso-is-enabled/203378/2 "2021-09-13T10:56:08Z")

</div>

Ah, I think I may have solved my own problem.

I needed to modify the discourse-sdk to include the “Accept” json header in its requests:

```javascript
request.get({
        url: getUrl,
        headers: {
            'Accept': 'application/json'
        },
    },

```

Looks like maybe the discourse-sdk didn’t work in the first place, aside from my SSO complications
