Mattermost auth failure - Bad response from token request
### Summary
When migrating a mattermost install to a new server 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. I'm not sure if it's related to restoring from an old install.
### Steps to reproduce
* Install gitlab-ce omnibus package on Ubuntu 18.04
* Restore gitlab.rb.
* Restore gitlab from backup
* Restore mattermost:
```
gitlab-ctl stop
gitlab-ctl start postgresql
sudo -u gitlab-psql -H /opt/gitlab/embedded/bin/dropdb -U gitlab-psql -h /var/opt/gitlab/postgresql -p 5432 mattermost_production
sudo -u gitlab-psql /opt/gitlab/embedded/bin/createdb -U gitlab-psql -h /var/opt/gitlab/postgresql -p 5432 mattermost_production
sudo -u mattermost /opt/gitlab/embedded/bin/psql -U gitlab_mattermost -h /var/opt/gitlab/postgresql -p 5432 mattermost_production < 2019_04_06_1554526861_mattermost.sql
```
Restore mattermost data.
```
rm -rf /var/opt/gitlab/mattermost
mkdir /var/opt/gitlab/mattermost
chown mattermost:mattermost /var/opt/gitlab/mattermost
tar xvf /var/data/backup/2019_04_06_1554526861_mattermost.tar.gz --directory /var/opt/gitlab/mattermost
chown -R mattermost:mattermost /var/opt/gitlab/mattermost
```
Start gitlab and reconfigure.
```
gitlab-ctl stop postgresql
gitlab-ctl start
gitlab-ctl reconfigure
gitlab-ctl restart
```
* Fix auth urls in /admin/applications
### 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.
### Relevant logs and/or screenshots
<details>
<summary>Expand for `gitlab-ctl tail` log during a login attempt.</summary>
<pre>
==> /var/log/gitlab/nginx/gitlab_mattermost_access.log <==
REDACTED - - [07/Apr/2019:20:06:23 -0500] "GET /oauth/gitlab/login HTTP/2.0" 302 0 "" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/REDACTED Safari/537.36"
REDACTED - - [07/Apr/2019:20:06:23 -0500] "POST /oauth/token HTTP/1.1" 301 178 "" "mattermost-5.8.0"
REDACTED - - [07/Apr/2019:20:06:23 -0500] "GET /oauth/token HTTP/1.1" 200 3366 "https://REDACTED/oauth/token" "mattermost-5.8.0"
REDACTED - - [07/Apr/2019:20:06:23 -0500] "GET /signup/gitlab/complete?code=REDACTED HTTP/2.0" 500 644 "" "Mozilla/5.0 (X11;
Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/REDACTED
Safari/537.36"
==> /var/log/gitlab/nginx/gitlab_access.log <==
REDACTED - - [07/Apr/2019:20:06:23 -0500] "GET /oauth/authorize?response_type=code&client_id=REDACTED &redirect_uri=https%3A%2F%2FREDACTED%2Fsignup%2Fgitlab%2Fcomplete&state=REDACTED HTTP/2.0" 302 321 "" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/REDACTED Safari/537.36"
==> /var/log/gitlab/nginx/gitlab_mattermost_access.log <==
REDACTED - - [07/Apr/2019:20:06:23 -0500] "GET /favicon.ico HTTP/2.0" 200 3366 "https://REDACTED/signup/gitlab/complete" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/REDACTED Safari/537.36"
REDACTED - - [07/Apr/2019:20:06:23 -0500] "GET /error?message=Bad+response+from+token+request&s=REDACTED= HTTP/2.0" 200 3366 "https://REDACTED/signup/gitlab/complete" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/REDACTED Safari/537.36"
REDACTED - - [07/Apr/2019:20:06:23 -0500] "GET /api/v4/license/client?format=old HTTP/2.0" 200 22 "" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/REDACTED Safari/537.36"
REDACTED - - [07/Apr/2019:20:06:23 -0500] "GET /api/v4/config/client?format=old HTTP/2.0" 200 2167 "" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/REDACTED Safari/537.36"
REDACTED - - [07/Apr/2019:20:06:23 -0500] "GET /api/v4/plugins/webapp HTTP/2.0" 200 2 "" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/REDACTED Safari/537.36"
</pre>
</details>
#### Results of GitLab environment info
<details>
<summary>Expand for output related to GitLab environment info</summary>
<pre>
`gitlab-rake gitlab:env:info`)
System information
System: Ubuntu 18.04
Current User: git
Using RVM: no
Ruby Version: 2.5.3p105
Gem Version: 2.7.6
Bundler Version:1.16.6
Rake Version: 12.3.2
Redis Version: 3.2.12
Git Version: 2.18.1
Sidekiq Version:5.2.5
Go Version: unknown
GitLab information
Version: 11.9.6
Revision: 14bac95b643
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: postgresql
URL: https://REDACTED.com
HTTP Clone URL: https://REDACTED.com/some-group/some-project.git
SSH Clone URL: ssh://git@https://REDACTED.com:27271/some-group/some-project.git
Using LDAP: no
Using Omniauth: yes
Omniauth Providers:
GitLab Shell
Version: 8.7.1
Repository storage paths: default: /var/data/git-data/repositories
GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell
Git: /opt/gitlab/embedded/bin/git
</pre>
</details>
#### Results of GitLab application Check
<details>
<summary>Expand for output related to the GitLab application check</summary>
<pre>
gitlab-rake gitlab:check SANITIZE=true
Checking GitLab subtasks ...
Checking GitLab Shell ...
GitLab Shell: ... GitLab Shell version >= 8.7.1 ? ... OK (8.7.1)
Running /opt/gitlab/embedded/service/gitlab-shell/bin/check
Check GitLab API access: OK
Redis available via internal API: OK
Access to /var/opt/gitlab/.ssh/authorized_keys: OK
gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Gitaly ...
Gitaly: ... default ... OK
Checking Gitaly ... Finished
Checking Sidekiq ...
Sidekiq: ... Running? ... yes
Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Checking Incoming Email ...
Incoming Email: ... Reply by email is disabled in config/gitlab.yml
Checking Incoming Email ... Finished
Checking LDAP ...
LDAP: ... LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab App ...
Git configured correctly? ... yes
Database config exists? ... yes
All migrations up? ... yes
Database contains orphaned GroupMembers? ... no
GitLab config exists? ... yes
GitLab config up to date? ... yes
Log directory writable? ... yes
Tmp directory writable? ... yes
Uploads directory exists? ... yes
Uploads directory has correct permissions? ... yes
Uploads directory tmp has correct permissions? ... yes
Init script exists? ... skipped (omnibus-gitlab has no init script)
Init script up-to-date? ... skipped (omnibus-gitlab has no init script)
Projects have namespace: ...
6/8 ... yes
[SNIP]
Redis version >= 2.8.0? ... yes
Ruby version >= 2.3.5 ? ... yes (2.5.3)
Git version >= 2.18.0 ? ... yes (2.18.1)
Git user has default SSH configuration? ... yes
Active users: ... 15
Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished
</pre>
</details>
issue