{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["img"]},"type":"markdown"},"seo":{"title":"Authentication","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"authentication","__idx":0},"children":["Authentication"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["MoreLogin uses different authentication methods for its two API types."]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"local-api-authentication","__idx":1},"children":["Local API Authentication"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Local API runs on ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["http://127.0.0.1:40000"]}," and is accessible only from the local machine."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"default-mode-no-authentication","__idx":2},"children":["Default Mode (No Authentication)"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["By default, the Local API does not require authentication. You can make requests directly:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"curl -X POST http://127.0.0.1:40000/api/env/page \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"pageNo\": 1,\n    \"pageSize\": 10\n  }'\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"enabling-authentication","__idx":3},"children":["Enabling Authentication"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For enhanced security, you can enable Local API authentication in the MoreLogin client:"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Open the MoreLogin client"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Navigate to ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Settings"]}," → ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["API & MCP"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Enable ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Local API Authentication"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Copy the generated authorization token"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/image.590455fe8c04c7aec45454ddba2524af46ee8128e15fbef43221c071f4863f91.8f1e5674.png","alt":"Enable Local API Authentication"},"children":[]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["After enabling, include the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Authorization"]}," header in all requests:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"curl -X POST http://127.0.0.1:40000/api/env/page \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Authorization: YOUR_AUTH_TOKEN\" \\\n  -d '{\n    \"pageNo\": 1,\n    \"pageSize\": 10\n  }'\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Security Note"]},": The Local API is only available on ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["localhost"]},". It cannot be accessed remotely."]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"open-api-authentication-oauth2","__idx":4},"children":["Open API Authentication (OAuth2)"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Open API uses OAuth2 client credentials flow to authenticate requests."]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Open API Server endpoint: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://api.morelogin.com"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"step-1-get-api-id-and-api-key","__idx":5},"children":["Step 1: Get API ID and API Key"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Open the MoreLogin client"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Navigate to ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Settings"]}," → ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["API & MCP"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Copy the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["API ID"]}," and ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["API Key"]}]}]},{"$$mdtype":"Tag","name":"Image","attributes":{"src":"/assets/image.5fd3488a120b7d8e2f400229cb0ad75e34ad8299fa6cfc9c304c29662ff9ade1.e358a1d4.png","alt":"API ID and Key","withLightbox":true,"width":"","height":""},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"step-2-get-access-token","__idx":6},"children":["Step 2: Get Access Token"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Exchange your API ID and API Key for an access token:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"curl -X POST https://api.morelogin.com/oauth2/token \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"client_id\": \"YOUR_API_ID\",\n    \"client_secret\": \"YOUR_API_KEY\",\n    \"grant_type\": \"client_credentials\"\n  }'\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Sample Response:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n    \"code\": 0,\n    \"msg\": null,\n    \"data\": {\n        \"scope\": \"cloudphone\",\n        \"access_token\": \"eyJ0eXAiOiJKV1QiLCJhbGciOi...\",\n        \"token_type\": \"Bearer\",\n        \"expires_in\": 3600,\n        \"client_metadata\": {\n            \"name\": \"Example Team\"\n        }\n    },\n    \"requestId\": \"4b727b1d53a445d0a46389465b562360\"\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"step-3-use-access-token","__idx":7},"children":["Step 3: Use Access Token"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Include the access token in the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Authorization"]}," header for all Open API requests:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"curl -X POST https://api.morelogin.com/cloudphone/app/page \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Authorization: Bearer YOUR_ACCESS_TOKEN\" \\\n  -d '{\n    \"pageNum\": 1,\n    \"pageSize\": 10\n  }'\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Note"]},": Access tokens expire after ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["3600 seconds"]}," (1 hour). Request a new token when the current one expires."]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"authentication-comparison","__idx":8},"children":["Authentication Comparison"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Feature"},"children":["Feature"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Local API"},"children":["Local API"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Open API"},"children":["Open API"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Method"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Static token (optional)"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["OAuth2 access token"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Token Lifetime"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Permanent (until regenerated)"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["1 hour"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Where to Get"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["MoreLogin client settings"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Exchange API ID + Key"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Header Format"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Authorization: TOKEN"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Authorization: Bearer TOKEN"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Required"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Optional (can be disabled)"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Always required"]}]}]}]}]}]},"headings":[{"value":"Authentication","id":"authentication","depth":1},{"value":"Local API Authentication","id":"local-api-authentication","depth":2},{"value":"Default Mode (No Authentication)","id":"default-mode-no-authentication","depth":3},{"value":"Enabling Authentication","id":"enabling-authentication","depth":3},{"value":"Open API Authentication (OAuth2)","id":"open-api-authentication-oauth2","depth":2},{"value":"Step 1: Get API ID and API Key","id":"step-1-get-api-id-and-api-key","depth":3},{"value":"Step 2: Get Access Token","id":"step-2-get-access-token","depth":3},{"value":"Step 3: Use Access Token","id":"step-3-use-access-token","depth":3},{"value":"Authentication Comparison","id":"authentication-comparison","depth":2}],"frontmatter":{"seo":{"title":"Authentication"}},"lastModified":"2026-05-11T01:22:01.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/api-reference/getting-started/authentication","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}