[SOLVED] How to authenticate bots using the API

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?

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

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"

Thanks @jurgenhaas for posting back your solution!

@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 … a related question … and added more detail there.

Thanks.

@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.

Thanks for responding @jurgenhaas