{"_id":"57efe333dbc6523200f268fc","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"},"githubsync":"","user":"5542d87d795b590d001dc7ff","parentDoc":null,"project":"5589ceae9883a40d00c433f3","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"},"__v":2,"metadata":{"title":"","description":"","image":[]},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-10-01T16:24:19.352Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[{"status":200,"name":"","code":"{\n  \"id\": \"usr_TgTbetyiSvuiIw\",\n  \"name\": \"Jane Smith\",\n  \"username\": \"janes5\",\n  \"email\": \"jane.smith:::at:::example.com\",\n  \"verified_email\": null,\n  \"verified_phone\": \"+15552323353\",\n  \"auth_type\": \"two_factor\",\n  \"disabled\": false,\n  \"created\": 1473544359.3973701,\n  \"last_failed_login\": null,\n  \"last_login\": null\n}","language":"json"},{"name":"","code":"{\n  \"error\": {\n    \"type\": \"user_authentication_error\",\n    \"code\": \"unauthorized\",\n    \"message\": \"User unauthorized\",\n    \"retry_wait\": null\n  }\n}","language":"json","status":400}]},"settings":"","examples":{"codes":[{"language":"curl","code":"curl https://api.userkit.io/v1/users/by_token \\\n -u api:sk_atKYtmX64nGRWbvuv6FXq2CG.app_6fa64vtE \\\n -H \"X-User-Token: {SESSION_TOKEN}\""},{"language":"python","code":"uk = userkit.UserKit(\"{YOUR_APP_SECRET_KEY}\")\n\nuser = uk.users.get_current_user(\n  \"{SESSION_TOKEN}\")"},{"language":"ruby","code":"require 'json'\nrequire 'rest-client'\n\ndef get_current_user(session_token)\n  resource = RestClient::Resource.new(\n    'https://api.userkit.io/v1/users/by_token',\n    'api', '{YOUR_APP_SECRET_KEY}')\n  begin\n \t\tresponse = resource.get(:'X-User-TOken' => session_token)\n    return JSON.parse(response.body)\n \trescue RestClient::Exception\n  \treturn nil\n  end\nend\n\n\nuser = get_current_user(\"{SESSION_TOKEN}\")"},{"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  user, _ := uk.Users.GetUserBySession(\n    \"{SESSION_TOKEN}\")\n\tfmt.Printf(\"%+v\", user)\n}","language":"go"},{"code":"<?php\n\n$uk = new UserKit('<YOUR_APP_SECRET_KEY>');\n\n$user = $uk->users->getCurrentUser('<SESSION_TOKEN>');","language":"php"}]},"method":"get","auth":"required","params":[{"_id":"57efe3d62b028c3400e6bed6","ref":"","in":"header","required":false,"desc":"The session token for a logged in user","default":"","type":"string","name":"X-User-Token"}],"url":"/v1/users/by_token"},"isReference":true,"order":4,"body":"","excerpt":"Use a session token to get the logged in user","slug":"fetch-a-logged-in-user-by-session","type":"endpoint","title":"Fetch a logged in user by session"}

getFetch a logged in user by session

Use a session token to get the logged in user

Definition

{{ api_url }}{{ page_api_url }}

Parameters

Headers

X-User-Token:
string
The session token for a logged in user

Examples


Result Format


User Information

Try It Out

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