Can't authenticate via curl after setting up docker evaluation version

Summary

My company have asked me to do a simple evaluation of Mattermost.
They want me to confirm that channels can be created programatically.

Steps to reproduce

I create the Docker evaluation installation using the instructions at:

http://docs.mattermost.com/install/docker-local-machine.html

I verified that I can login via the web interface.

But when I try to acquire a authentication token via curl I get the following error:

HTTP/1.1 400 Bad Request
Content-Type: application/json
X-Ratelimit-Limit: 10
X-Ratelimit-Remaining: 9
X-Ratelimit-Reset: 1
X-Request-Id: zt33utt497gjdyujpc9hiynmqy
X-Version-Id: 3.0.0.1466368946
Date: Wed, 20 Jul 2016 17:07:14 GMT
Content-Length: 281

{"id":"store.sql_user.get_for_login.app_error","message":"We couldn't find an existing account matching your credentials. This team may require an invite from the team owner to join.","detailed_error":"","request_id":"zt33utt497gjdyujpc9hiynmqy","status_code":400,"is_oauth":false}```

Do I need to enable something?

Hi @sprintshot_guy,

Can you log into the web app, go to the System Console (the first account you created should have access to this), go to Settings > Authentication > Email in the left side menu, and verify that Enable sign-in with email is enabled? That 400 error should only be returned when you’ve entered an incorrect email or username as the login_id.

Also, you don’t need to specify the “name” property when calling the login API any more. It’s not used any more so it’s just getting ignored.

Since my first message, I switched to using the Ubuntu 16.04 install
of the server but still experiencing the same problems.

I see the System Console but I don’t see:
Settings -> Authentication -> Email.
The closest is:
Settings -> Email Settings.

I don’t see ‘Enable sign-in with Email’ but I do see ‘Enable Sign Up With Email’.
It’s set to true. I’ve tested creating new user account and verifying via email links.
That works.

I’m finding the API extremely hard to use.
I’m using 1.4.0 of the software.
But what version of the API am I using?
I see mention of v1 and v3 in the (sparse) documentation.
What is the correct curl call to obtain an authentication token?
Do I use the username I created or the email I signed up with?

When I run bin/platform -version
I see:

$ bin/platform -version
Version: 1.4.0
Build Number: 5232
Build Date: Thu Jan 14 23:10:40 UTC 2016
Build Hash: 8089487d5caccbc642e9fef8ee0e5930ff1e639d
Build Enterprise Ready: false

My attempts to use curl get the following response:

$ curl -i -d ‘{“team_name”:“springshot”,“login_id”:“guy.argo@springshot.com”,“password”:"******"}’ http://racerslounge.chat:8065/api/v1/users/login
HTTP/1.1 403 Forbidden
Content-Type: application/json
X-Ratelimit-Limit: 10
X-Ratelimit-Remaining: 9
X-Ratelimit-Reset: 1
X-Request-Id: 1u55y5qaujfb7jbkifte8y1z4a
X-Version-Id: 1.4.0.1469641268
Date: Wed, 27 Jul 2016 17:51:25 GMT
Content-Length: 170

{“message”:“Either user id or team name and user email must be provided”,“detailed_error”:"",“request_id”:"1u55y5qaujfb7jbkifte8y1z4a

What are the precise fields I need to use?
What values should be in those fields?

Very frustrated.
Guy

Oh sorry, I should’ve asked what version of Mattermost you were running. Our API documentation is already limited for the current version, but it’s practically nonexistent for older ones.

If you’re just using the instance for a trial run, I’d recommend deleting the existing preview instance if possible and starting out with one running Mattermost 3.2. There’s some pretty significant changes since 1.4, particularly in Mattermost 3.0, that make it difficult to upgrade from pre-3.0.

Mattermost 3.2

If you switch to Mattermost 3.2, we provide a Javascript driver and a Go driver to make interacting with Mattermost easier than with the command line. If you’re not using either of those, the following API calls will log in an existing user and create a channel on a team that they’re already a member of:

  1. Log in
curl -i -d '{"login_id:":"example@example.com","password":"PASSWORD"}' http://example.com:8065/api/v3/users/login

And copy the authentication token from the line that looks like

Token: TOKEN
  1. List the user’s teams to get the ID of the team to create the channel on
curl -i -H 'Authorization Bearer TOKEN' http://example.com:8065/api/v3/users/teams/all

That will return a dictionary of the user’s teams. You’ll want to get the id field of one of your teams

{"TEAM_ID":{"id":"TEAM_ID", "name": "yourteamhere", ...}}
  1. Create the channel
curl -i -H 'Authorization: Bearer TOKEN' -d '{"name": "new-channel", "team_id": "TEAM_ID", "type": "O"}' http://example.com:8065/api/v3/teams/TEAM_ID/channels/create

Mattermost 1.4

It’s been a while since I’ve looked at the old API, and I don’t have a 1.4 instance available to test them on at this moment, but these steps should create the channel for you.

  1. Log in to get the token
curl -i -d '{"name":"springshot","email:":"guy.argo@springshot.com","password":"******"}' http://racerslounge.chat:8065/api/v1/users/login
  1. Instead of getting the team ID from a separate API call, it’ll be available as part of the previously returned user object
{"id": "abcd1234", "team_id": "TEAMID", ...}
  1. Create the channel, same as above, but using the v1 api version
curl -i -H 'Authorization: Bearer TOKEN' -d '{"name": "new-channel", "team_id": "TEAM_ID", "type": "O"}' http://example.com:8065/api/v1/teams/TEAM_ID/channels/create

What version of the server software is compatible with your mobile clients?
I upgraded to 3.4 but then I found that none of the mobile clients work.

All versions since at least 3.0 should be compatible with the apps that are available on the App Store and Google Play Store. What sort of behaviour are you seeing from the apps? They make just take a moment to load depending on your signal strength.

Also, is there anything logged to the server when you try to connect to them with the mobile app? The logs are available in the System Console > Other > Logs section on the webapp or in /mm/mattermost/logs/mattermost.log directly on the docker instance.