# Add to Mattermost returns No Session could be setup

**URL:** https://forum.mattermost.com/t/add-to-mattermost-returns-no-session-could-be-setup/3619
**Category:** Troubleshooting
**Created:** [August 2, 2017, 2:52pm UTC](https://forum.mattermost.com/t/add-to-mattermost-returns-no-session-could-be-setup/3619 "2017-08-02T14:52:54Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![swashata](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/swashata/32/1458_2.png) [@swashata](https://forum.mattermost.com/u/swashata)
#### Post date: [August 2, 2017, 2:52pm UTC](https://forum.mattermost.com/t/add-to-mattermost-returns-no-session-could-be-setup/3619/1 "2017-08-02T14:52:54Z")

</div>

# Summary

When I am trying to add the integration with mattermost slash command, I follow the Add to Mattermost button. But it is returning `No session could be set up, is Mattermost configured with Single Sign On?`

# Steps to reproduce

- Install Mattermost through omnibus. As referred [here](https://docs.gitlab.com/omnibus/gitlab-mattermost/)
- Go to Any Project \> Settings \> Integration and click on Mattermost Slash Commands.
- Click on Add to Mattermost

 ![2017-08-02_20-21-23](https://us1.discourse-cdn.com/flex020/uploads/mattermost/original/2X/7/7d86ee17db98cba77177de746d2e87a000063856.gif)

Currently running GitLab 9.4.3  
with the following `/etc/gitlab/gitlab.rb`

```ruby
external_url "https://wpquark.io"
nginx['redirect_http_to_https'] = true
nginx['ssl_certificate'] = "/etc/letsencrypt/live/wpquark.io/fullchain.pem"
nginx['ssl_certificate_key'] = "/etc/letsencrypt/live/wpquark.io/privkey.pem"
nginx['custom_gitlab_server_config'] = "location ^~ /.well-known { root /var/www/letsencrypt; }"

# SMTP Emailing
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "some.mail.server"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "no-reply@wpquark.io"
gitlab_rails['smtp_password'] = "supersecretpassword"
gitlab_rails['smtp_domain'] = "wpquark.io"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_openssl_verify_mode'] = 'peer'
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = 'no-reply@wpquark.io'
gitlab_rails['gitlab_email_reply_to'] = 'no-reply@wpquark.io'

# MatterMost
mattermost_external_url 'http://chat.wpquark.io'
mattermost_nginx['custom_gitlab_mattermost_server_config'] = "location ^~ /.well-known { root /var/www/mattermost; }"

#mattermost['email_enable_sign_in_with_email'] = true
mattermost['email_enable_sign_up_with_email'] = true
mattermost['email_send_email_notifications'] = true
mattermost['email_smtp_username'] = "no-reply@wpquark.io"
mattermost['email_smtp_password'] = "supersecretpassword"
mattermost['email_smtp_server'] = "some.mail.server"
mattermost['email_smtp_port'] = "465"
mattermost['email_connection_security'] = 'TLS'
mattermost['email_feedback_name'] = "WPQuark Chat"
mattermost['email_feedback_email'] = "no-reply@wpquark.io"
mattermost['service_enable_incoming_webhooks'] = true
mattermost['service_enable_commands'] = true
mattermost['service_enable_only_admin_integrations'] = true

```

The relevant portion of the Mattermost log file at /var/log/gitlab/mattermost/mattermost.log

```txt
2017-08-02_14:17:17.02101 [2017/08/02 19:47:17 IST] [INFO] Server is listening on 127.0.0.1:8065
2017-08-02_14:17:17.02244 [2017/08/02 19:47:17 IST] [INFO] Starting jobs
2017-08-02_14:19:25.44265 [2017/08/02 19:49:25 IST] [EROR] AuthorizeOAuthUser: Invalid state,
2017-08-02_14:22:24.40188 [2017/08/02 19:52:24 IST] [EROR] AuthorizeOAuthUser: Invalid state,
2017-08-02_14:25:13.28750 [2017/08/02 19:55:13 IST] [EROR] AuthorizeOAuthUser: Invalid state,
2017-08-02_14:35:49.50315 [2017/08/02 20:05:49 IST] [INFO] Config file watcher detected a change reloading /var/opt/gitlab/matt$2017-08-02_14:35:49.77653 [2017/08/02 20:05:49 IST] [INFO] Stopped jobs
2017-08-02_14:35:49.77673 [2017/08/02 20:05:49 IST] [INFO] Stopping Server...
2017-08-02_14:35:49.77673 [2017/08/02 20:05:49 IST] [INFO] Closing SqlStore
2017-08-02_14:35:50.05346 [2017/08/02 20:05:50 IST] [INFO] Loaded system translations for 'en' from '/opt/gitlab/embedded/servi$2017-08-02_14:35:51.63763 [2017/08/02 20:05:51 IST] [INFO] Current version is 4.0.0 (4.0.2/Fri Jul 28 19:49:45 UTC 2017/f71cc06$2017-08-02_14:35:51.63766 [2017/08/02 20:05:51 IST] [INFO] Enterprise Enabled: false
2017-08-02_14:35:51.63766 [2017/08/02 20:05:51 IST] [INFO] Current working directory is /opt/gitlab/embedded/service/mattermost 2017-08-02_14:35:51.63766 [2017/08/02 20:05:51 IST] [INFO] Loaded config file from /var/opt/gitlab/mattermost/config.json
2017-08-02_14:35:51.63767 [2017/08/02 20:05:51 IST] [INFO] Server is initializing...
2017-08-02_14:35:51.63767 [2017/08/02 20:05:51 IST] [INFO] Pinging SQL master database
2017-08-02_14:35:51.64092 [2017/08/02 20:05:51 IST] [INFO] Pinging SQL replica-0 database
2017-08-02_14:35:51.67810 [2017/08/02 20:05:51 IST] [INFO] Initializing job API routes
2017-08-02_14:35:51.69171 [2017/08/02 20:05:51 IST] [INFO] API version 3 is scheduled for deprecation. Please see https://api.m$2017-08-02_14:35:51.69172 [2017/08/02 20:05:51 IST] [INFO] Starting 8 websocket hubs
2017-08-02_14:35:51.76472 [2017/08/02 20:05:51 IST] [INFO] Starting Server...
2017-08-02_14:35:51.76474 [2017/08/02 20:05:51 IST] [INFO] Server is listening on 127.0.0.1:8065
2017-08-02_14:35:51.76549 [2017/08/02 20:05:51 IST] [INFO] Starting jobs
2017-08-02_14:36:59.25564 [2017/08/02 20:06:59 IST] [EROR] AuthorizeOAuthUser: Invalid state,
2017-08-02_14:41:28.66887 [2017/08/02 20:11:28 IST] [EROR] AuthorizeOAuthUser: Invalid state,
2017-08-02_14:42:17.68168 [2017/08/02 20:12:17 IST] [EROR] AuthorizeOAuthUser: Invalid state,
2017-08-02_14:45:30.08326 [2017/08/02 20:15:30 IST] [EROR] AuthorizeOAuthUser: Invalid state,

```

Is is due to the fact that gitlab is using `https` and mattermost `http`. I can’t test right now because let’s encrypt is still waiting for DNS propagation.

---

<div class="post-metadata">

### Author: ![swashata](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/swashata/32/1458_2.png) [@swashata](https://forum.mattermost.com/u/swashata)
#### Post date: [August 2, 2017, 4:00pm UTC](https://forum.mattermost.com/t/add-to-mattermost-returns-no-session-could-be-setup/3619/2 "2017-08-02T16:00:42Z")

</div>

Okay I have setup SSL and now the mattermost is at [https://chat.wpquark.io](https://chat.wpquark.io) But the issue is still there. ☹

---

<div class="post-metadata">

### Author: ![swashata](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/swashata/32/1458_2.png) [@swashata](https://forum.mattermost.com/u/swashata)
#### Post date: [August 2, 2017, 4:22pm UTC](https://forum.mattermost.com/t/add-to-mattermost-returns-no-session-could-be-setup/3619/3 "2017-08-02T16:22:40Z")

</div>

After trying a lot, I finally settled with the Slask Slash commands. It works just fine. 🙂

---

<div class="post-metadata">

### Author: ![lindy65](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/lindy65/32/1811_2.png) [@lindy65](https://forum.mattermost.com/u/lindy65)
#### Post date: [August 7, 2017, 7:43am UTC](https://forum.mattermost.com/t/add-to-mattermost-returns-no-session-could-be-setup/3619/4 "2017-08-07T07:43:43Z")

</div>

Hi @swashata,

Thank you for your feedback,

I’m pleased you’ve managed to resolve your issue and thank you for posting back your solution!
