{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","results":{"codes":[]},"settings":"","params":[]},"next":{"description":"","pages":[]},"title":"Authentication","type":"basic","slug":"lrs-connect-api","excerpt":"","body":"Authentication to LRS Connect API uses OAuth 2.0. \n\n * Your api key and secret are accessed from the user management page within LRS Connect. \n * Credentials can be deleted and regenerated to control access. \n * A single set of credentials can provide access to data for multiple accounts.\n * Data for inactive accounts will not be returned. \n[block:api-header]\n{\n \"type\": \"post\",\n \"title\": \"/rest/v3/oauth/token\"\n}\n[/block]\nMethod needs to invoked with a header value \n[block:parameters]\n{\n \"data\": {\n \"h-0\": \"Header\",\n \"h-1\": \"Value\",\n \"h-2\": \"Description\",\n \"0-0\": \"user\",\n \"0-1\": \"Example: \\n\\nM0lZZZhFUDRIOFY1R0lSNUw0MEsx...vbE5UMEZ0NWVVOEFkYkkw\",\n \"0-2\": \"`user` header value should contain a base64 encoded string consisting of the API Key ID and API Key Secret which can be found within the user management page of LRSConnect.\\n\\ne.g. base64(API_ID:API_SECRET\"\n },\n \"cols\": 3,\n \"rows\": 1\n}\n[/block]\n\n[block:api-header]\n{\n \"type\": \"basic\",\n \"title\": \"Request\"\n}\n[/block]\nIn order to receive token, `?grant_type=client_credentials` MUST be appended to token URI.\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"// OAuth (POST https://connect.lrsus.com/rest/v3/oauth/token)\\n\\n$.ajax({\\n url: \\\"https://connect.lrsus.com/rest/v3/oauth/token?grant_type=client_credentials\\\",\\n type: \\\"POST\\\",\\n headers: {\\n \\\"user\\\": \\\"M0lYUUhFUDRIOFY1...bE5UMEZ0NWVVOEFkYkkw\\\",\\n },\\n})\\n.done(function(data, textStatus, jqXHR) {\\n console.log(\\\"HTTP Request Succeeded: \\\" + jqXHR.status);\\n console.log(data);\\n})\\n.fail(function(jqXHR, textStatus, errorThrown) {\\n console.log(\\\"HTTP Request Failed\\\");\\n})\\n.always(function() {\\n /* ... */\\n});\",\n \"language\": \"javascript\"\n },\n {\n \"code\": \"import java.io.IOException;\\nimport org.apache.http.client.fluent.*;\\n\\npublic class SendRequest\\n{\\n public static void main(String[] args) {\\n sendRequest();\\n }\\n \\n private static void sendRequest() {\\n \\n // OAuth (POST )\\n \\n try {\\n \\n // Create request\\n Content content = Request.Post(\\\"https://connect.lrsus.com/rest/v3/oauth/token?grant_type=client_credentials\\\")\\n \\n // Add headers\\n .addHeader(\\\"user\\\", \\\"M0lYUUhFUDRIOFY1...bE5UMEZ0NWVVOEFkYkkw\\\")\\n \\n // Fetch request and return content\\n .execute().returnContent();\\n \\n // Print content\\n System.out.println(content);\\n }\\n catch (IOException e) { System.out.println(e); }\\n }\\n}\",\n \"language\": \"java\"\n },\n {\n \"code\": \"// OAuth (GET https://connect.lrsus.com/rest/v3/oauth/token)\\n\\nNSURL* URL = [NSURL URLWithString::::at:::\\\"https://connect.lrsus.com/rest/v3/oauth/token?grant_type=client_credentials\\\"];\\nNSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:URL];\\nrequest.HTTPMethod = @\\\"POST\\\";\\n\\n// Headers\\n\\n[request addValue:@\\\"M0lYUUhFUDRIOFY1...bE5UMEZ0NWVVOEFkYkkw\\\" forHTTPHeaderField:@\\\"user\\\"];\\n\\n// Connection\\n\\nNSURLConnection* connection = [NSURLConnection connectionWithRequest:request delegate:nil];\\n[connection start];\\n\",\n \"language\": \"objectivec\"\n },\n {\n \"code\": \"curl -X \\\"POST\\\" \\\"https://connect.lrsus.com/rest/v3/oauth/token?grant_type=client_credentials\\\" \\\\\\n\\t-H \\\"user: M0lYUUhFUDRIOFY1...bE5UMEZ0NWVVOEFkYkkw\\\"\",\n \"language\": \"curl\"\n },\n {\n \"code\": \"# Install the Python Requests library:\\n# `pip install requests`\\n\\nimport requests\\n\\ndef send_request():\\n # OAuth (GET https://connect.lrsus.com/rest/v3/oauth/token)\\n\\n try:\\n r = requests.post(\\n url=\\\"https://connect.lrsus.com/rest/v3/oauth/token?grant_type=client_credentials\\\",\\n headers = {\\n \\\"user\\\":\\\"M0lYUUhFUDRIOFY1...bE5UMEZ0NWVVOEFkYkkw\\\",\\n },\\n )\\n print('Response HTTP Status Code : {status_code}'.format(status_code=r.status_code))\\n print('Response HTTP Response Body : {content}'.format(content=r.content))\\n except requests.exceptions.RequestException as e:\\n print('HTTP Request failed')\\n\",\n \"language\": \"python\"\n }\n ]\n}\n[/block]\n\n[block:api-header]\n{\n \"type\": \"basic\",\n \"title\": \"Response 200 (application/json)\"\n}\n[/block]\nThe response will contain a \"Bearer\" token that must be passed on subsequent requests. The token is valid for 1200 seconds by default.\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"{\\n \\\"expires_in\\\": \\\"1200\\\",\\n \\\"token_type\\\": \\\"Bearer\\\",\\n \\\"access_token\\\": \\\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0ODQxNTU3MzksInN1YiI6IjVTMEZCMUZJQzFSSE5HOUNFSElTNVBHUDAiLCJpc3MiOiJodHRwczovL2FwaS5zdG9ybXBhdGguY29tL3YxL2FwcGxpY2F0aW9ucy81c3VtdGdod3A2Vkw2cUdTbUN3VDJjIiwiaWF0IjoxNDg0MTU0NTM5fQ.SInKB-Q7Ouhz43itJsmxBvr5vgyhUmkwf8Zga8AF7Oc\\\"\\n}\",\n \"language\": \"json\",\n \"name\": \"JSON\"\n }\n ]\n}\n[/block]\nThe token is passed as an Authorization header value. \n[block:parameters]\n{\n \"data\": {\n \"h-0\": \"Header\",\n \"h-1\": \"Value\",\n \"h-2\": \"Description\",\n \"0-0\": \"Authorization\",\n \"0-1\": \"Example:\\n\\nBearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0MzU3N...FWFxGl3odgJ25T0O7kwq-hca2QDtSIWKUFHTpBNU97c\",\n \"0-2\": \"Concatenate value of \\\"Bearer\\\" and `access_token` returned from /rest/v3/oauth/token method.\"\n },\n \"cols\": 3,\n \"rows\": 1\n}\n[/block]\n\n[block:api-header]\n{\n \"type\": \"basic\",\n \"title\": \"SSL\"\n}\n[/block]\nSSL is used to encrypt all requests to & from LRS Connect API.","updates":[],"order":1,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"58766da64a24f82f00bbf288","category":{"sync":{"isSync":false,"url":""},"pages":[],"title":"Documentation","slug":"documentation","order":0,"from_sync":false,"reference":false,"_id":"58766da64a24f82f00bbf286","version":"58766da54a24f82f00bbf285","project":"552819c1555b9e0d00564f74","createdAt":"2015-04-10T18:43:14.538Z","__v":0},"user":"55157a70c859ac2f0001b535","__v":0,"version":{"version":"3.0","version_clean":"3.0.0","codename":"","is_stable":true,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["58766da64a24f82f00bbf286","5e97f10ca9631a0231d9c19a"],"_id":"58766da54a24f82f00bbf285","releaseDate":"2017-01-11T17:38:45.993Z","project":"552819c1555b9e0d00564f74","__v":2,"createdAt":"2017-01-11T17:38:45.993Z"},"createdAt":"2015-07-01T14:45:40.136Z","githubsync":"","project":"552819c1555b9e0d00564f74"}