Skip to main content
MindTouch Success Center

users/authenticate (GET) (MT4)

Overview

Authenticate a user given http header Credentials or an auth token. Response status 200 implies valid credentials and contains a new auth token.

  • REST Method: GET
  • Method Access: public

Query Parameters

Name Type Description
callback string? If specified, return response as a jsonp call using the provided callback.
ssotoken string? Token from remote auth service to be used for internal SSO authentication.
authprovider int? Identifier for the external service to use for authentication.
redirect uri? Redirect to the given URI upon authentication

Return Codes

Name Value Description
OK 200 The request completed successfully
Bad Request 400 Invalid input parameter or request body
Unauthorized 401 Login has failed
Conflict 409 Username conflicts with an existing username

Message Format

Output:
Content-type=text/plain

Implementation Notes

If the login credentials are valid, this feature returns an authentication token in the response text and an 'authtoken' cookie. This cookie can be used with subsequent requests to execute using the  login credentials.

C# Code Sample: Authenticate User and Retrieve Authtoken

The following code example authenticates the the "admin" user using the local authentication service:

Sample Code

Plug p = Plug.New("http://deki-hayes/@api/deki");
DreamMessage msg = p.At("users", "authenticate").WithCredentials("admin", "password").Get();
String cookieText = msg.Cookies[0].ToString();

Sample Response from executing Code

Sample authtoken cookie contents:

$Version=1; authtoken=1_633245325345625000_12276545af9bf1f3c24c382c7211760a; $Path=/; $Domain=deki-hayes

Curl Code Sample: Authenticate User and Retrieve Authtoken

The following command authenticates a user and returns an authtoken that can be used in a cookie:

Sample Code

curl -u username:password -i http://mindtouch.address/@api/deki/users/authenticate

Sample Response from executing Code

Sample authtoken string

Content-Type: text/plain

78_634007511287248014_85a251d22b9e98cd1197f652fe59e255

Implementation notes 

curl flags

-u
Provides external user authentication.
-i
Outputs the HTTP response headers. Useful for debugging.
  • Was this article helpful?