{"_id":"57efe21845f5d92200b8e2db","category":{"_id":"57d4a754899ab90e00105e5d","project":"5589ceae9883a40d00c433f3","__v":0,"version":"5589ceae9883a40d00c433f6","sync":{"url":"","isSync":false},"reference":true,"createdAt":"2016-09-11T00:37:40.706Z","from_sync":false,"order":2,"slug":"tutorials","title":"Server API"},"version":{"_id":"5589ceae9883a40d00c433f6","__v":10,"project":"5589ceae9883a40d00c433f3","createdAt":"2015-06-23T21:25:02.865Z","releaseDate":"2015-06-23T21:25:02.865Z","categories":["5589ceaf9883a40d00c433f7","559ab19d2100d117005f1269","57d4a754899ab90e00105e5d","5807813b6d24211900953b99","5819154bf62fee0f00949855","5841d27cae05ac2500ba2680","5846c4ee5d064323007b1774","589e29c72793e937001c15c5","5cf0460e272f2c0014a80d17","5cf047bde14258005d7a374e"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"user":"5542d87d795b590d001dc7ff","__v":1,"parentDoc":null,"githubsync":"","project":"5589ceae9883a40d00c433f3","metadata":{"title":"","description":"","image":[]},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-10-01T16:19:36.357Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[{"status":200,"language":"json","code":"{\n  \"token\": \"usr_j3LB5QPAH8B9UD:KJmrd2N4O4tgE1AkZMoX0tPhlTT1NDQfVblRJ96ln2G|sha256\", \n  \"expires_in_secs\": 86399.832370000004, \n  \"refresh_after_secs\": 77759.832439999998\n}","name":""},{"name":"","status":400,"language":"json","code":"{\n  \"error\": {\n    \"type\": \"user_authentication_error\",\n    \"code\": \"unauthorized\",\n    \"message\": \"Wrong login or password.\",\n    \"retry_wait\": 30.0  // Or null\n  }\n}"}]},"settings":"","examples":{"codes":[{"language":"curl","code":"curl https://api.userkit.io/v1/users/login \\\n -u api:{YOUR_APP_SECRET_KEY} \\\n -H \"Content-Type: application/json\" \\\n -d '{\"username\": \"jane.smith:::at:::example.com\", \"password\": \"secretpass\"}'"},{"language":"python","code":"uk = userkit.UserKit(\"{YOUR_APP_SECRET_KEY}\")\n\n# param 1: email, username or phone.\n# param 2: password.\n# param 3 (OPTIONAL): 2-factor or on-demand\n# \t\t\t\tlogin code.\nsession = uk.users.login_user(\n  \"jane.smith@example.com\", \"secretpass\")"},{"code":"def login_user(username, password=nil,\n  \t\t\t\t\t\tlogin_code=nil)\n    url = 'https://api.userkit.io/v1/users/login'\n    resource = RestClient::Resource.new(url,\n      'api', '{YOUR_APP_SECRET_KEY}')\n    data = {:username => username}\n    if password\n        data['password'] = password\n    end\n    if login_code\n        data['login_code'] = login_code\n    end\n    response = resource.post(\n        data.to_json,\n        :content_type => 'application/json')\n    return JSON.parse(response.body)\nend\n\n# Param 1: email, username or phone.\n# Param 2: password.\n# Param 3 (optional): 2-factor or on-demand\n#\t\t\t\t\tlogin code.\nsession = login_user(\"jane.smith@example.com\",\n  \"secretpass\")","language":"ruby"},{"language":"go","code":"package main\n\nimport (\n\t\"fmt\"\n\tuserkit \"github.com/workpail/userkit-go\"\n)\n\nfunc main() {\n  uk := userkit.NewUserKit(\n    \"{YOUR_APP_SECRET_KEY}\")\n  \n  // param 1: username, email or phone\n  // param 2: password\n  // param 3: OPTIONAL 2-factor or on-demand\n  //          login code\n  session, _ := uk.Users.Login(\n    \"js@example.com\", \"secretpass\", \"\")\n\tfmt.Printf(\"%+v\", user)\n}"},{"code":"<?php\n\n$uk = new UserKit('<YOUR_APP_SECRET_KEY>');\n\n// param 1: email, username or phone.\n// param 2: password.\n// param 3 (OPTIONAL): 2-factor or on-demand\n// \t\t\t\tlogin code.\n$session = $uk->users->loginUser('jane.smith@example.com', 'secretpass');","language":"php"}]},"method":"post","auth":"required","params":[{"_id":"57efddcc8daa662b00d94fdc","ref":"","in":"body","required":false,"desc":"A user identifier, this can be a username, email or phone number","default":"","type":"string","name":"username"},{"_id":"57efddcc8daa662b00d94fdb","ref":"","in":"body","required":false,"desc":"The user's password","default":"","type":"string","name":"password"},{"_id":"57efddcc8daa662b00d94fda","ref":"","in":"body","required":false,"desc":"OPTIONAL, a two-factor or on-demand login code if user's account has this turned on","default":"","type":"string","name":"login_code"}],"url":"/v1/users/login"},"isReference":true,"order":3,"body":"","excerpt":"Your users can login with the widget, but you can also login a user directly via the API","slug":"login-a-user","type":"endpoint","title":"Login a user"}

postLogin a user

Your users can login with the widget, but you can also login a user directly via the API

Definition

{{ api_url }}{{ page_api_url }}

Parameters

Body Params

username:
string
A user identifier, this can be a username, email or phone number
password:
string
The user's password
login_code:
string
OPTIONAL, a two-factor or on-demand login code if user's account has this turned on

Examples


Result Format


User Information

Try It Out

post
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}