{"id":761,"date":"2019-11-05T09:57:33","date_gmt":"2019-11-05T08:57:33","guid":{"rendered":"https:\/\/www.trans.eu\/api\/?p=761"},"modified":"2025-12-09T09:22:15","modified_gmt":"2025-12-09T08:22:15","slug":"access-token","status":"publish","type":"post","link":"https:\/\/www.trans.eu\/api\/uncategorized\/access-token\/","title":{"rendered":"Access token"},"content":{"rendered":"\n<p>This autho\u00adriza\u00adtion method is no longer sup\u00adport\u00aded. For infor\u00adma\u00adtion method on how to obtain access_token please refer to <a href=\"https:\/\/www.trans.eu\/api\/general-information\/authorization-process\/\" title>autho\u00adriza\u00adtion using JWT<\/a>.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Using all of API meth\u00adods requires authen\u00adti\u00adca\u00adtion. It is nec\u00ades\u00adsary to have a valid cus\u00adtomer account on the Trans.eu Plat\u00adform. The login and pass\u00adword will be used to obtain the token, which is manda\u00adto\u00adry to use the API meth\u00adods.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Method: GET<\/li>\n\n\n\n<li>Host: https:\/\/auth.system.trans.eu<\/li>\n\n\n\n<li>URL: \/oauth2\/authorize?<\/li>\n\n\n\n<li>Para\u00adme\u00adters: client_id=example_app_client_id\n<ul class=\"wp-block-list\">\n<li>response_type=code<\/li>\n\n\n\n<li>redirect_uri=https:\/\/example.com\/applicationendpoint<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>HTTP\/1.1<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Request parameters (in query string)<\/h2>\n\n\n\n<figure class=\"wp-block-table has-small-font-size\"><table><tbody><tr><td>Name<\/td><td>Required<\/td><td>Type<\/td><td>Descrip\u00adtion<\/td><\/tr><tr><td>response_type<\/td><td>yes<\/td><td>string<\/td><td>Must be set to code.<\/td><\/tr><tr><td>client_id<\/td><td>yes<\/td><td>string<\/td><td>Client ID obtained dur\u00ading appli\u00adca\u00adtion reg\u00adis\u00adtra\u00adtion.<\/td><\/tr><tr><td>redirect_uri<\/td><td>yes<\/td><td>string<\/td><td>One of pre\u00advi\u00adous\u00adly spec\u00adi\u00adfied appli\u00adca\u00adtion redi\u00adrect end\u00adpoints.<\/td><\/tr><tr><td>state<\/td><td>no<\/td><td>string<\/td><td>Ran\u00addom gen\u00ader\u00adat\u00aded string, that will be includ\u00aded in request response to prove response ori\u00adgin. Helps pre\u00advent\u00ading <a href=\"https:\/\/en.wikipedia.org\/wiki\/Cross-site_request_forgery\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">CSRF attacks.<\/a><\/td><\/tr><tr><td>scope<\/td><td>no<\/td><td>string<\/td><td>Space sep\u00ada\u00adrat\u00aded list of scopes that appli\u00adca\u00adtion would like to access.<\/td><\/tr><tr><td>source<\/td><td>no<\/td><td>string<\/td><td>Choose ser\u00advice to ver\u00adi\u00adfy cre\u00adden\u00adtials against.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>The Trans Autho\u00adriza\u00adtion Serv\u00ader will dis\u00adplay page with details of request\u00aded scopes. If the user is not signed in, he first has to sign in using his Trans or Transplace cre\u00adden\u00adtials.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Authorization response<\/h2>\n\n\n\n<p>When user grants appli\u00adca\u00adtion access to request\u00aded scopes, Trans Autho\u00adriza\u00adtion Serv\u00ader will redi\u00adrect user back to URI spec\u00adi\u00adfied in redirect_uri para\u00adme\u00adter along with gen\u00ader\u00adat\u00aded code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>HTTP\/1.1 302 Found<\/li>\n\n\n\n<li>Loca\u00adtion: https:\/\/example.com\/applicationpoint?code=SDF41D54F54D45DF4<\/li>\n<\/ul>\n\n\n\n<p>Response para\u00adme\u00adters<\/p>\n\n\n\n<figure class=\"wp-block-table has-small-font-size\"><table><tbody><tr><td>Name<\/td><td>Type<\/td><td>Descrip\u00adtion<\/td><\/tr><tr><td>code<\/td><td>string<\/td><td>Autho\u00adriza\u00adtion code gen\u00ader\u00adat\u00aded by the Trans Autho\u00adriza\u00adtion Serv\u00ader.<\/td><\/tr><tr><td>state<\/td><td>string<\/td><td>Val\u00adue of the state para\u00adme\u00adter pro\u00advid\u00aded in autho\u00adriza\u00adtion request.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Warn\u00ading: For secu\u00adri\u00adty rea\u00adsons code life\u00adtime is lim\u00adit\u00aded to 1 minute, after that peri\u00adod it becomes invalid. Also please note that not every error will cause a redi\u00adrect. If the request fails due to a miss\u00ading, invalid, or mis\u00admatch\u00ading redi\u00adrect URI or client id, the Trans Autho\u00adriza\u00adtion Serv\u00ader inform user about this on its own page.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Access token request<\/h2>\n\n\n\n<p>After receiv\u00ading valid code from the Trans Autho\u00adriza\u00adtion Serv\u00ader, appli\u00adca\u00adtion can make request to the token end\u00adpoint and exchange code for access token.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Host: auth.system.trans.eu<\/li>\n\n\n\n<li>POST \/oauth2\/token<\/li>\n\n\n\n<li>Con\u00adtent-Type: appli\u00adca\u00adtion\/x\u2011www-form-urlen\u00adcod\u00aded<\/li>\n\n\n\n<li>grant_type=authorization_code<\/li>\n\n\n\n<li>code=a1c94032558c6d0ba98b998299a63135bce063b1<\/li>\n\n\n\n<li>redirect_uri=https:\/\/example.com\/applicationendpoint<\/li>\n\n\n\n<li>client_id=example_app_client_id<\/li>\n\n\n\n<li>client_secret=example_app_secret<\/li>\n<\/ul>\n\n\n\n<p>Response para\u00adme\u00adters<\/p>\n\n\n\n<figure class=\"wp-block-table has-small-font-size\"><table><tbody><tr><td>Name<\/td><td>Type<\/td><td>Descrip\u00adtion<\/td><\/tr><tr><td>code<\/td><td>string<\/td><td>Autho\u00adriza\u00adtion code gen\u00ader\u00adat\u00aded by the Trans Autho\u00adriza\u00adtion Serv\u00ader.<\/td><\/tr><tr><td>state<\/td><td>string<\/td><td>Val\u00adue of the state para\u00adme\u00adter pro\u00advid\u00aded in autho\u00adriza\u00adtion request.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Warn\u00ading: For secu\u00adri\u00adty rea\u00adsons code life\u00adtime is lim\u00adit\u00aded to 1 minute, after that peri\u00adod it becomes invalid. Also please note that not every error will cause a redi\u00adrect. If the request fails due to a miss\u00ading, invalid, or mis\u00admatch\u00ading redi\u00adrect URI or client id, the Trans Autho\u00adriza\u00adtion Serv\u00ader inform user about this on its own page.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Access token request<\/h2>\n\n\n\n<p>After receiv\u00ading valid code from the Trans Autho\u00adriza\u00adtion Serv\u00ader, appli\u00adca\u00adtion can make request to the token end\u00adpoint and exchange code for access token.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>POST \/oauth2\/token<\/li>\n\n\n\n<li>Host: auth.system.trans.eu<\/li>\n\n\n\n<li>Con\u00adtent-Type: appli\u00adca\u00adtion\/x\u2011www-form-urlen\u00adcod\u00aded<\/li>\n\n\n\n<li>grant_type=authorization_code<\/li>\n\n\n\n<li>code=a1c94032558c6d0ba98b998299a63135bce063b1<\/li>\n\n\n\n<li>redirect_uri=https:\/\/example.com\/applicationendpoint<\/li>\n\n\n\n<li>client_id=example_app_client_id<\/li>\n\n\n\n<li>client_secret=example_app_secret<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Request parameters<\/h2>\n\n\n\n<figure class=\"wp-block-table has-small-font-size\"><table><tbody><tr><td>Name<\/td><td>Required<\/td><td>Type<\/td><td>Descrip\u00adtion<\/td><\/tr><tr><td>grant_type<\/td><td>yes<\/td><td>string<\/td><td>Must be set to authorization_code.<\/td><\/tr><tr><td>code<\/td><td>yes<\/td><td>string<\/td><td>Valid autho\u00adriza\u00adtion code received from the Trans Autho\u00adriza\u00adtion Serv\u00ader.<\/td><\/tr><tr><td>redirect_uri<\/td><td>yes<\/td><td>string<\/td><td>The same redirect_uri as pro\u00advid\u00aded when retriev\u00ading code.<\/td><\/tr><tr><td>client_id<\/td><td>no<\/td><td>string<\/td><td>Appli\u00adca\u00adtion client_id obtained dur\u00ading reg\u00adis\u00adtra\u00adtion. Only required when Autho\u00adriza\u00adtion head\u00ader is not sent.<\/td><\/tr><tr><td>client_secret<\/td><td>no<\/td><td>string<\/td><td>Appli\u00adca\u00adtion client_secret obtained dur\u00ading reg\u00adis\u00adtra\u00adtion. Only required when Autho\u00adriza\u00adtion head\u00ader is not sent.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Access token response<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>Example HTTP\/1.1 200 OK Content-Type: application\/json <\/code><\/pre><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>{\n  \"access_token\": \"59d9aa9b15cd59a61fc52014792efb6caa82373b\",\n  \"expires_in\": 21599,\n  \"token_type\": \"Bearer\",\n  \"scope\": \"offers.loads.manage\",\n  \"refresh_token\": \"d52d1d998d6533a3be8e7f26f904be513287938b\"\n}<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Response parameters<\/h2>\n\n\n\n<figure class=\"wp-block-table has-small-font-size\"><table><tbody><tr><td>Name<\/td><td>Descrip\u00adtion<\/td><\/tr><tr><td>access_token<\/td><td>Access token to use by appli\u00adca\u00adtion for autho\u00adriza\u00adtion.<\/td><\/tr><tr><td>expires_in<\/td><td>Time in sec\u00adonds until token expires.<\/td><\/tr><tr><td>token_type<\/td><td>Type Bear\u00ader is returned as defined in <a>rfc6749.<\/a><\/td><\/tr><tr><td>scope<\/td><td>Space sep\u00ada\u00adrat\u00aded list of scopes that access token has access to.<\/td><\/tr><tr><td>refresh_token<\/td><td>Sin\u00adgle serv\u00ading token that can be used to extend life\u00adtime of access token.<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p class=\"dont-break-out\">This autho\u00adriza\u00adtion method is no longer sup\u00adport\u00aded. For infor\u00adma\u00adtion method on how to obtain access_token please refer to autho\u00adriza\u00adtion using \u2026<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"wp_typography_post_enhancements_disabled":false,"footnotes":""},"categories":[120],"tags":[],"class_list":["post-761","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"acf":[],"aioseo_notices":[],"lang":"en","translations":{"en":761},"pll_sync_post":[],"_links":{"self":[{"href":"https:\/\/www.trans.eu\/api\/wp-json\/wp\/v2\/posts\/761","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.trans.eu\/api\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trans.eu\/api\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trans.eu\/api\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trans.eu\/api\/wp-json\/wp\/v2\/comments?post=761"}],"version-history":[{"count":3,"href":"https:\/\/www.trans.eu\/api\/wp-json\/wp\/v2\/posts\/761\/revisions"}],"predecessor-version":[{"id":5566,"href":"https:\/\/www.trans.eu\/api\/wp-json\/wp\/v2\/posts\/761\/revisions\/5566"}],"wp:attachment":[{"href":"https:\/\/www.trans.eu\/api\/wp-json\/wp\/v2\/media?parent=761"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trans.eu\/api\/wp-json\/wp\/v2\/categories?post=761"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trans.eu\/api\/wp-json\/wp\/v2\/tags?post=761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}