# SSO\_SYNC not working

**URL:** https://meta.discourse.org/t/sso-sync-not-working/87150
**Category:** SSO
**Created:** [May 10, 2018, 9:26am UTC](https://meta.discourse.org/t/sso-sync-not-working/87150 "2018-05-10T09:26:18Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![shahidmir](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@shahidmir](https://meta.discourse.org/u/shahidmir)
#### Post date: [May 10, 2018, 9:26am UTC](https://meta.discourse.org/t/sso-sync-not-working/87150/1 "2018-05-10T09:26:18Z")

</div>

Hi Guys

I need some assistance with the /admin/users/sso\_sync end point.  
Using postman, I am trying to update an email address using this end point, but postman is returning a HTML page as response (which is basically the landing page of my application where discourse is integrated).

Im doing a POST to:

```
https:{my domain}/admin/users/sync_sso

```

With body:

```
{
	"email":"test@gmail.com",
	"external_id":"xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
	"require_activation":"false",
	"api_key":"xxxxxxxxxxxxx",
	"api_username":"admin users email address"
}

```

For the api\_username, i have tried both admin user’s email address as well as username, but none works.  
Is the api\_username something else?  
Can someone advise where Im going wrong.

Regards

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [May 10, 2018, 10:30am UTC](https://meta.discourse.org/t/sso-sync-not-working/87150/2 "2018-05-10T10:30:03Z")

</div>

As per

> [@Sync DiscourseConnect user data with the sync\_sso route](https://meta.discourse.org/t/sync-sso-user-data-with-the-sync-sso-route/84398):
>
> Single Sign On can be used to handle Discourse user authentication from a separate site. The [Setup DiscourseConnect - Official Single-Sign-On for Discourse (sso)](https://meta.discourse.org/t/official-single-sign-on-for-discourse-sso/13045) topic has details about how to implement [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) . The Problem With [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) , Discourse users will be created or updated when they login to Discourse from your external website. What it doesn’t handle is when you need to create or update Discourse users without having them login to your site. For sites that are using…

You have to use the following:

```plaintext
$api_username = 'system';

```

---

<div class="post-metadata">

### Author: ![shahidmir](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@shahidmir](https://meta.discourse.org/u/shahidmir)
#### Post date: [May 10, 2018, 11:07am UTC](https://meta.discourse.org/t/sso-sync-not-working/87150/3 "2018-05-10T11:07:20Z")

</div>

Hi,

thanks for that. Using the api\_username=system takes me one step further, but I am now getting an error regarding an invalid ‘sig’, which is not something i pass neither suggested to pass?

`RuntimeError (Bad signature for payload sso: sig: expected sig: a03011b1a83a925095b984c265fbe1e65f3351e6edfee38cbbf1b3c1015630f2) /var/www/discourse/lib/single_sign_on.rb:30:in `parse’`

any ideas?

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [May 10, 2018, 11:10am UTC](https://meta.discourse.org/t/sso-sync-not-working/87150/4 "2018-05-10T11:10:31Z")

</div>

I’m not very familiar with that endpoint and @simon wrote that howto so maybe he can help!

Edit:  
are you initializing sig as:

```plaintext
$sig = hash_hmac( 'sha256', $sso_payload, $sso_secret );

```

---

<div class="post-metadata">

### Author: ![shahidmir](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@shahidmir](https://meta.discourse.org/u/shahidmir)
#### Post date: [May 10, 2018, 11:19am UTC](https://meta.discourse.org/t/sso-sync-not-working/87150/5 "2018-05-10T11:19:36Z")

</div>

No, I am not. Reading the documentation, I assumed I could call the end point with payload excluding nonce, sig and it would work. @sam, could you please advise on this too, have an urgent deadline to meet on this.  
Using a Java application, I simply want to make a rest call to that end point to update the email, silently.

---

<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: [May 10, 2018, 3:57pm UTC](https://meta.discourse.org/t/sso-sync-not-working/87150/6 "2018-05-10T15:57:57Z")

</div>

> [@shahidmir](#):
>
> I assumed I could call the end point with payload excluding nonce

This is correct. You do not need the `nonce` in the payload for the `sync_sso` route. The body of the POST request needs the following parameters: `sso`, `sig`, `api_key`, `api_username`.

To see how to create the `sso` and `sig` parameters, read the ‘Setup the SSO parameters’ section of this topic: [Sync DiscourseConnect user data with the sync\_sso route](https://meta.discourse.org/t/sync-sso-user-data-with-the-sync-sso-route/84398).

The return value of a successful call to `/admin/users/sync_sso` is a Discourse User object.

---

<div class="post-metadata">

### Author: ![shahidmir](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@shahidmir](https://meta.discourse.org/u/shahidmir)
#### Post date: [May 10, 2018, 4:13pm UTC](https://meta.discourse.org/t/sso-sync-not-working/87150/7 "2018-05-10T16:13:46Z")

</div>

thank you simon, i have it almost working now.
