# \[SOLVED\] How to authenticate bots using the API

**URL:** <https://forum.mattermost.com/t/solved-how-to-authenticate-bots-using-the-api/2405>\
**Category:** Troubleshooting\
**Created:** [October 24, 2016, 3:43pm UTC](https://forum.mattermost.com/t/solved-how-to-authenticate-bots-using-the-api/2405 "2016-10-24T15:43:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jurgenhaas](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/jurgenhaas/32/471_2.png) [@jurgenhaas](https://forum.mattermost.com/u/jurgenhaas)\
**Post date:** [October 24, 2016, 3:43pm UTC](https://forum.mattermost.com/t/solved-how-to-authenticate-bots-using-the-api/2405/1 "2016-10-24T15:43:27Z")

</div>

When Mattermost is installed with GitLab and uses GitLab SSO, I wonder how we could integrate with bots. In my use case, webhooks are no option because the outgoing webhooks are not available for private channels. So I wanted to use a bot that uses the API and therefore should login as a bot user to Mattermost. But that doesn’t seem possible when SSO with Gitlab is enabled. Is there something I’m missing?

---

<div class="post-metadata">

**Author:** ![jurgenhaas](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/jurgenhaas/32/471_2.png) [@jurgenhaas](https://forum.mattermost.com/u/jurgenhaas)\
**Post date:** [October 24, 2016, 4:22pm UTC](https://forum.mattermost.com/t/solved-how-to-authenticate-bots-using-the-api/2405/2 "2016-10-24T16:22:19Z")

</div>

Found the answer. You need to create a user from the CLI which is not a SSO user:

```auto
cd /opt/gitlab/embedded/service/mattermost/i18n
sudo -u mattermost /opt/gitlab/embedded/bin/mattermost -config="/var/opt/gitlab/mattermost/config.json" -create_user -team_name="name" -email="user@example.com" -password="mypassword"

```

---

<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:** [October 27, 2016, 9:41am UTC](https://forum.mattermost.com/t/solved-how-to-authenticate-bots-using-the-api/2405/3 "2016-10-27T09:41:25Z")

</div>

Thanks @jurgenhaas for posting back your solution!

---

<div class="post-metadata">

**Author:** ![mccoole](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/mccoole/32/706_2.png) [@mccoole](https://forum.mattermost.com/u/mccoole)\
**Post date:** [January 31, 2017, 7:31pm UTC](https://forum.mattermost.com/t/solved-how-to-authenticate-bots-using-the-api/2405/4 "2017-01-31T19:31:12Z")

</div>

@jurgenhaas

I was wondering if you were able to solve how to get a [session token] for a user where mattermost is set-up as part of gitlab. Given that authentication is happening against gitlab, it seems the mattermost user lacks a ‘password’ to pass for logging in via the mattermost API and therefore gets rejected.

I asked over [here](http://forum.mattermost.com/t/launch-queries-on-the-mattermost-api-having-gitlab-as-authentication-provider/2625/3) … a related question … and added more detail there.

Thanks.

---

<div class="post-metadata">

**Author:** ![jurgenhaas](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/jurgenhaas/32/471_2.png) [@jurgenhaas](https://forum.mattermost.com/u/jurgenhaas)\
**Post date:** [February 1, 2017, 7:14am UTC](https://forum.mattermost.com/t/solved-how-to-authenticate-bots-using-the-api/2405/5 "2017-02-01T07:14:58Z")

</div>

@mccoole I got it working with an explicitly created user for Mattermost as described above. As that is working just fine, I’ve never followed up on this issue trying anything else.

---

<div class="post-metadata">

**Author:** ![mccoole](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/mccoole/32/706_2.png) [@mccoole](https://forum.mattermost.com/u/mccoole)\
**Post date:** [February 1, 2017, 8:39am UTC](https://forum.mattermost.com/t/solved-how-to-authenticate-bots-using-the-api/2405/6 "2017-02-01T08:39:39Z")

</div>

Thanks for responding @jurgenhaas
