{"id":2478,"date":"2023-12-12T14:54:09","date_gmt":"2023-12-12T14:54:09","guid":{"rendered":"https:\/\/developers.maplink.global\/how-do-i-generate-the-token-for-authentication\/"},"modified":"2024-02-27T20:33:12","modified_gmt":"2024-02-27T20:33:12","slug":"how-do-i-generate-the-token-for-authentication","status":"publish","type":"post","link":"https:\/\/developers.maplink.global\/en\/how-do-i-generate-the-token-for-authentication\/","title":{"rendered":"How do I generate the token for authentication?"},"content":{"rendered":"\n<p>To use Maplink&#8217;s APIs, you need to generate a <em><strong>bearer token<\/strong><\/em>from your unique credentials.<\/p>\n\n<p>Each <em>bearer token <\/em>lasts 60 minutes and can be used by any API. After this interval you will need to generate a new token.<\/p>\n\n<p>Below is an example of the unique credentials that must be used in a <em>body <\/em>when generating the <em>bearer token<\/em>:<\/p>\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">client_id: 0wf*************************eqFG\nclient_secret: 1b***********owE<\/pre>\n\n<p>With the client_id and client_secret, use the following endpoint with the <strong>POST<\/strong> method to obtain the <em>bearer token<\/em>:  <\/p>\n\n<p><a href=\"https:\/\/api.maplink.global\/oauth\/client_credential\/accesstoken?grant_type=client_credentials\">https:\/\/api.maplink.global\/oauth\/client_credential\/accesstoken?grant_type=client_credentials<\/a><\/p>\n\n<h2 class=\"wp-block-heading\">Request example<\/h2>\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">curl -X POST \"https:\/\/api.maplink.global\/oauth\/client_credential\/accesstoken?grant_type=client_credentials\" -H\n\n\"Content-Type: application\/x-www-form-urlencoded\" --data-urlencode \"client_id=0wf*************************eqFG\" --data-urlencode \"client_secret=1b***********owE\"<\/pre>\n\n<h2 class=\"wp-block-heading\">Response example<\/h2>\n\n<p>The <strong>&#8220;access_token&#8221; : &#8220;XBlgpdua80eonaU7FmRjhRsjMe3c&#8221;<\/strong> is the one that should be used to authenticate requests from the other APIs for 60 minutes.<\/p>\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"json\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{\n    \"refresh_token_expires_in\": \"0\",\n    \"api_product_list\": \"[Matrix, Restriction Zone, Trip, Planning, Toll, Place, Geocode, Toll Search]\",\n    \"api_product_list_json\": [\n        \"Matrix\",\n        \"Trip\",\n        \"Planning\",\n        \"Toll\",\n        \"Geocode\"    ],\n    \"organization_name\": \"lbslocal\",\n    \"developer.email\": \"abcde@abcde.com\",\n    \"token_type\": \"BearerToken\",\n    \"issued_at\": \"1620249207151\",\n    \"client_id\": \"0wf*************************eqFG\",\n    \"access_token\": \"XBlgpdua80eonaU7FmRjhRsjMe3c\",\n    \"application_name\": \"49136471-81b0-4f23-bfff-980f0337f01e\",\n    \"scope\": \"\",\n    \"expires_in\": \"3599\",\n    \"refresh_count\": \"0\",\n    \"status\": \"approved\"\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>To use Maplink&#8217;s APIs, you need to generate a bearer tokenfrom your unique credentials. Each bearer token lasts 60 minutes and can be used by any API. After this interval you will need to generate a new token. Below is an example of the unique credentials that must be used in a body when generating [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[159],"tags":[],"class_list":["post-2478","post","type-post","status-publish","format-standard","hentry","category-before-starting"],"acf":[],"_links":{"self":[{"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/posts\/2478","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/comments?post=2478"}],"version-history":[{"count":1,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/posts\/2478\/revisions"}],"predecessor-version":[{"id":2479,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/posts\/2478\/revisions\/2479"}],"wp:attachment":[{"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/media?parent=2478"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/categories?post=2478"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/tags?post=2478"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}