{"id":257,"date":"2023-11-29T18:39:49","date_gmt":"2023-11-29T18:39:49","guid":{"rendered":"https:\/\/olxdoc.wpenginepowered.com\/?p=257"},"modified":"2024-03-11T07:03:28","modified_gmt":"2024-03-11T07:03:28","slug":"oauth2-generate-authorization-token-2","status":"publish","type":"post","link":"https:\/\/doc.olxgroup.com\/api\/?p=257","title":{"rendered":"Oauth2 &#8211; Generate authorization token"},"content":{"rendered":"\r\n<p>All resources exposed by API are restricted ones and user authentication (and subsequent authorization with token) is required to access .<\/p>\r\n<p><strong>POST: <\/strong><a href=\"https:\/\/www.autovit.ro\/api\/open\/oauth\/token\">https:\/\/www.autovit.ro\/api\/open\/oauth\/token<\/a><\/p>\r\n<h2>Parameter<\/h2>\r\n<table>\r\n<thead>\r\n<tr>\r\n<th>Field<\/th>\r\n<th>Type<\/th>\r\n<th>Description<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr>\r\n<td>client_id<\/td>\r\n<td>Number<\/td>\r\n<td>Unique API client ID<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>client_secret<\/td>\r\n<td>String<\/td>\r\n<td>Client secret code<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>grant_type<\/td>\r\n<td>String<\/td>\r\n<td>Allowed grant types: &#8220;password&#8221; or &#8220;partner&#8221;<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>username<\/td>\r\n<td>String<\/td>\r\n<td>Only for &#8220;password&#8221; grant type &#8211; user login (email)<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>password<\/td>\r\n<td>String<\/td>\r\n<td>Only for &#8220;password&#8221; grant type &#8211; user password<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>partner_code<\/td>\r\n<td>String<\/td>\r\n<td>Only for &#8220;partner&#8221; grant type &#8211; partner name<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>partner_secret<\/td>\r\n<td>String<\/td>\r\n<td>Only for &#8220;partner&#8221; grant type &#8211; partner password<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<p><strong class=\"bg-tag-blue font-bold tag\">Example curl request for &#8220;password&#8221; grant_type<\/strong><code>curl -X POST\r\n    -u client_id:client_secret\r\n    -d \"grant_type=password\"\r\n    -d \"username=user@sneaky.domain\"\r\n    -d \"password=gimmeaccess\"\r\n    http:\/\/{example.com}\/api\/open\/oauth\/token<\/code><button>Copy<\/button> curl -X POST -u client_id:client_secret -d &#8220;grant_type=password&#8221; -d &#8220;username=user@sneaky.domain&#8221; -d &#8220;password=gimmeaccess&#8221; http:\/\/{example.com}\/api\/open\/oauth\/token Copied to clipboard <strong class=\"bg-tag-blue font-bold tag\">Example raw request for &#8220;partner&#8221; grant_type<\/strong><code>POST \/oauth\/token HTTP\/1.1\r\nContent-Type: application\/x-www-form-urlencoded\r\nclient_id=123&amp;client_secret=02468abcdef&amp;partner_code=partner-name&amp;partner_secret=secret-code&amp;grant_type=partner<\/code><button>Copy<\/button> POST \/oauth\/token HTTP\/1.1 Content-Type: application\/x-www-form-urlencoded client_id=123&amp;client_secret=02468abcdef&amp;partner_code=partner-name&amp;partner_secret=secret-code&amp;grant_type=partner Copied to clipboard<\/p>\r\n<h2>Success 200<\/h2>\r\n<table>\r\n<thead>\r\n<tr>\r\n<th>Field<\/th>\r\n<th>Type<\/th>\r\n<th>Description<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr>\r\n<td>access_token<\/td>\r\n<td>String<\/td>\r\n<td>Authorization token to be used in subsequent requests<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>token_type<\/td>\r\n<td>String<\/td>\r\n<td>&#8220;bearer&#8221; only<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>expires_in<\/td>\r\n<td>Number<\/td>\r\n<td>Number of seconds to expire<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>refresh_token<\/td>\r\n<td>String<\/td>\r\n<td>Refresh token<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>scope<\/td>\r\n<td>String<\/td>\r\n<td>Access scope<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<p><strong class=\"text-green font-bold\">Success response<\/strong><code>HTTP\/1.1 200 OK\r\n{\r\n    \"access_token\": \"4df20e702bfaeee96ecd6cbbc4ff384c166f5567\",\r\n    \"token_type\": \"bearer\",\r\n    \"expires_in\": 43200,\r\n    \"refresh_token\": \"3901415998eb583aedabd027b93578df25ef93c6\",\r\n    \"scope\": \"adverts-write read\"\r\n}<\/code><button>Copy<\/button> HTTP\/1.1 200 OK { &#8220;access_token&#8221;: &#8220;4df20e702bfaeee96ecd6cbbc4ff384c166f5567&#8221;, &#8220;token_type&#8221;: &#8220;bearer&#8221;, &#8220;expires_in&#8221;: 43200, &#8220;refresh_token&#8221;: &#8220;3901415998eb583aedabd027b93578df25ef93c6&#8221;, &#8220;scope&#8221;: &#8220;adverts-write read&#8221; } Copied to clipboard <strong class=\"text-red font-bold\">Error response example:<\/strong><code>HTTP\/1.1 400 Bad request\r\n{\r\n    \"error\": \"invalid_grant\",\r\n    \"error_description\": \"Invalid partner credentials parameter\",\r\n    \"error_human_title\": \"Niepoprawna warto\u015b\u0107\",\r\n    \"error_human_message\": \"\"\r\n}<\/code><button>Copy<\/button> HTTP\/1.1 400 Bad request { &#8220;error&#8221;: &#8220;invalid_grant&#8221;, &#8220;error_description&#8221;: &#8220;Invalid partner credentials parameter&#8221;, &#8220;error_human_title&#8221;: &#8220;Niepoprawna warto\u015b\u0107&#8221;, &#8220;error_human_message&#8221;: &#8220;&#8221; } Copied to clipboard<\/p>\r\n","protected":false},"excerpt":{"rendered":"<p>All resources exposed by API are restricted ones and user authentication (and subsequent authorization with token) is required to access . POST: https:\/\/www.autovit.ro\/api\/open\/oauth\/token Parameter Field Type Description client_id Number Unique API client ID client_secret String Client secret code grant_type String Allowed grant types: &#8220;password&#8221; or &#8220;partner&#8221; username String Only for &#8220;password&#8221; grant type &#8211; user&#8230;  <a href=\"https:\/\/doc.olxgroup.com\/api\/?p=257\" title=\"Read Oauth2 &#8211; Generate authorization token\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[52],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/doc.olxgroup.com\/api\/index.php?rest_route=\/wp\/v2\/posts\/257"}],"collection":[{"href":"https:\/\/doc.olxgroup.com\/api\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/doc.olxgroup.com\/api\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/doc.olxgroup.com\/api\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/doc.olxgroup.com\/api\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=257"}],"version-history":[{"count":0,"href":"https:\/\/doc.olxgroup.com\/api\/index.php?rest_route=\/wp\/v2\/posts\/257\/revisions"}],"wp:attachment":[{"href":"https:\/\/doc.olxgroup.com\/api\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/doc.olxgroup.com\/api\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=257"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/doc.olxgroup.com\/api\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}