# Mattermost auth failure with GitLab omnibus

**URL:** <https://forum.mattermost.com/t/mattermost-auth-failure-with-gitlab-omnibus/7216>\
**Category:** Troubleshooting\
**Created:** [May 4, 2019, 7:37pm UTC](https://forum.mattermost.com/t/mattermost-auth-failure-with-gitlab-omnibus/7216 "2019-05-04T19:37:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnramsden](https://avatars.discourse-cdn.com/v4/letter/j/8e7dd6/32.png) [@johnramsden](https://forum.mattermost.com/u/johnramsden)\
**Post date:** [May 4, 2019, 7:37pm UTC](https://forum.mattermost.com/t/mattermost-auth-failure-with-gitlab-omnibus/7216/1 "2019-05-04T19:37:56Z")

</div>

#### Summary

When migrating a mattermost install to a new server, using GitLab omnibus, auth fails with ‘Bad response from token request’. I’ve attempted fresh installs multiple times purging everything and trying again multiple ways and the auth always fails.

[Related GitLab bug](https://gitlab.com/gitlab-org/gitlab-ce/issues/60171) where i’ve had no response yet.

#### Steps to reproduce

- Install gitlab-ce omnibus package on Ubuntu 18.04

- Restore gitlab.rb.

- Restore gitlab from backup

- Install mattermost:  
Start gitlab and reconfigure.

- Fix auth urls in /admin/applications

Here is my entire `gitlab.rb` (domain redacted), everything else is default:

```auto
external_url 'https://git.example.com'

gitlab_rails['gitlab_email_from'] = 'git@example.com'
gitlab_rails['gitlab_email_display_name'] = 'example.com git'
gitlab_rails['gitlab_username_changing_enabled'] = false
gitlab_rails['gitlab_default_projects_features_issues'] = false
gitlab_rails['gitlab_default_projects_features_wiki'] = false
gitlab_rails['backup_path'] = "/var/data/backup"
gitlab_rails['backup_keep_time'] = 691200
git_data_dirs({ 
  "default" => { 
    "path" => "/var/data/git-data"
  } 
})
gitlab_rails['gitlab_shell_ssh_port'] = 27271

nginx['redirect_http_to_https'] = true
nginx['ssl_protocols'] = "TLSv1.2"
nginx['custom_nginx_config'] = "include /etc/gitlab/nginx/sites-enabled/*;"

mattermost_external_url 'https://chat.example.com'
mattermost['enable'] = true
mattermost['team_site_name'] = "example.com Chat"
mattermost['gitlab_enable'] = true
mattermost['gitlab_id'] = "ID"
mattermost['gitlab_secret'] = "SECRET"
mattermost['gitlab_auth_endpoint'] = "https://git.example.com/oauth/authorize"
mattermost['gitlab_token_endpoint'] = "https://git.example.com/oauth/token"
mattermost['gitlab_user_api_endpoint'] = "https://git.example.com/api/v4/user"
mattermost['file_directory'] = "/var/data/mattermost/data"
mattermost_nginx['redirect_http_to_https'] = true
mattermost_nginx['listen_addresses'] = ['*', '[::]']

letsencrypt['enable'] = true

```

### What is the current _bug_ behavior?

Attempt to login - ‘Error Bad response from token request’

I was successful enabling login by email and logging in. Mattermost is working, and the correct urls show up in the system console. I also checked the token in gitlab and the console and they are the same.

---

<div class="post-metadata">

**Author:** ![amy.blais](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/amy.blais/32/7481_2.png) [@amy.blais](https://forum.mattermost.com/u/amy.blais)\
**Post date:** [May 6, 2019, 1:02pm UTC](https://forum.mattermost.com/t/mattermost-auth-failure-with-gitlab-omnibus/7216/2 "2019-05-06T13:02:08Z")

</div>

Hi @johnramsden,

Wondering if any of these older threads might help:

- [Bad response from token request after team creation auth](https://forum.mattermost.com/t/bad-response-from-token-request-after-team-creation-auth/895)
- [https://gitlab.com/gitlab-org/omnibus-gitlab/issues/2984](https://gitlab.com/gitlab-org/omnibus-gitlab/issues/2984)
- [https://github.com/mattermost/mattermost-server/issues/8636](https://github.com/mattermost/mattermost-server/issues/8636)

If not, please let me know and I will ask a developer for more details on this.

---

<div class="post-metadata">

**Author:** ![amy.blais](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/amy.blais/32/7481_2.png) [@amy.blais](https://forum.mattermost.com/u/amy.blais)\
**Post date:** [May 7, 2019, 2:37pm UTC](https://forum.mattermost.com/t/mattermost-auth-failure-with-gitlab-omnibus/7216/3 "2019-05-07T14:37:43Z")

</div>

@hmhealey Would you know if this is an issue on Mattermost side? The reporter originally posted this issue in Gitlab: [https://gitlab.com/gitlab-org/gitlab-ce/issues/60171](https://gitlab.com/gitlab-org/gitlab-ce/issues/60171).

---

<div class="post-metadata">

**Author:** ![hmhealey](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/hmhealey/32/1915_2.png) [@hmhealey](https://forum.mattermost.com/u/hmhealey)\
**Post date:** [May 8, 2019, 1:12pm UTC](https://forum.mattermost.com/t/mattermost-auth-failure-with-gitlab-omnibus/7216/4 "2019-05-08T13:12:03Z")

</div>

That configuration looks correct to me. If you run `gitlab-ctl tail mattermost` to view the logs while trying to log in, do those provide a more detailed error message?

---

<div class="post-metadata">

**Author:** ![johnramsden](https://avatars.discourse-cdn.com/v4/letter/j/8e7dd6/32.png) [@johnramsden](https://forum.mattermost.com/u/johnramsden)\
**Post date:** [May 8, 2019, 5:43pm UTC](https://forum.mattermost.com/t/mattermost-auth-failure-with-gitlab-omnibus/7216/5 "2019-05-08T17:43:55Z")

</div>

I removed the install, but `/var/log/gitlab/mattermost/mattermost.log` contains:

```
{"level":"error","ts":1554618871.9515939,"caller":"api4/oauth.go:493","msg":"AuthorizeOAuthUser:
Bad response from token request, response_body="}
{"level":"error","ts":1554618886.7511368,"caller":"web/context.go:52","msg":"Please sign in usin
g gitlab","path":"/api/v4/users/login","request_id":"h11xc1xf4by4tfttpri84ngkxo","ip_addr":"207.
216.83.234","user_id":"","method":"POST","err_where":"login","http_code":400,"err_details":""}

```

I’ll re-install so I can answer further questions.

---

<div class="post-metadata">

**Author:** ![hmhealey](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/hmhealey/32/1915_2.png) [@hmhealey](https://forum.mattermost.com/u/hmhealey)\
**Post date:** [May 10, 2019, 2:48pm UTC](https://forum.mattermost.com/t/mattermost-auth-failure-with-gitlab-omnibus/7216/6 "2019-05-10T14:48:54Z")

</div>

I guess that doesn’t provide much more information. I would’ve hoped that the `response_body=` would’ve included some more information after that instead of an empty string. Perhaps GitLab returned an error response with no body?

Did you happen to find out anything new after re-installing?
