{"id":12728,"date":"2020-04-30T16:44:54","date_gmt":"2020-04-30T15:44:54","guid":{"rendered":"https:\/\/developers.primaverabss.com\/en\/questions\/oauth2-client_credentials-jasmin-web-api\/"},"modified":"2020-05-04T12:49:33","modified_gmt":"2020-05-04T11:49:33","slug":"oauth2-client_credentials-jasmin-web-api","status":"publish","type":"cma_thread","link":"https:\/\/developers.ila.cegid.com\/en\/forum\/oauth2-client_credentials-jasmin-web-api\/","title":{"rendered":"oauth2 client_credentials jasmin web api"},"content":{"rendered":"<p>Boa tarde,<\/p>\n<pre class=\"cma_snippet_background\">Tenho estado a desenvolver uma aplica\u00e7\u00e3o com o grant_type \"client_credentials\", e fiz o seguinte teste com o curl no command line, \r\npara perceber o tipo de par\u00e2metros a usar nos 'GET's e 'POST's \u00e0 API do Jasmin.\r\nO que pretendo \u00e9 perceber a raz\u00e3o pela qual o API n\u00e3o me devolve o objeto protegido, devolve \"access forbidden\", e o que n\u00e3o estou a usar como devido.\r\n\r\n1. Obten\u00e7\u00e3o do access_token\r\ncurl -ik https:\/\/identity.primaverabss.com\/core\/connect\/token \\\r\n-H \"Accept: application\/json\" \\\r\n-H \"Accept-Language: en_US\" \\\r\n-u \"JASMIN-ITEMS:67bdc501-a421-4b3c-a6e4-56b5b1ddafaa\" \\\r\n-d \"grant_type=client_credentials\"\r\n==&gt; Obtenho o acess_token dentro de um objeto, como suposto.\r\n\r\n2. Obten\u00e7\u00e3o de dados do recurso Protegido: url = 'https:\/\/my.jasminsoftware.com\/api\/235177\/235177-0001\/invoiceReceipt\/invoices'\r\ncurl -i https:\/\/my.jasminsoftware.com\/api\/235177\/235177-0001\/invoiceReceipt\/invoices \\\r\n-H \"Content-Type: application\/json\" \\\r\n-H \"Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IkFEM0Q1RDJERjM4OTZBMDUwMzYwNzVDQkNFNDc0RDJBMjI4MUVCM0UiLCJ0eXAiOiJKV1QiLCJ4NXQiOiJyVDFkTGZPSmFnVURZSFhMemtkTktpS0I2ejQifQ.eyJuYmYiOjE1ODgyNDkzNzAsImV4cCI6MTU4ODI2Mzc3MCwiaXNzIjoiaHR0cHM6Ly9pZGVudGl0eS5wcmltYXZlcmFic3MuY29tIiwiYXVkIjpbImh0dHBzOi8vaWRlbnRpdHkucHJpbWF2ZXJhYnNzLmNvbS9yZXNvdXJjZXMiLCJqYXNtaW4iXSwiY2xpZW50X2lkIjoiSkFTTUlOLUlURU1TIiwic2NvcGUiOlsiYXBwbGljYXRpb24iXX0.5sozlyKaH8gAaWv5EW6t90JpyR-S5STARLLrvbsQl_x2QSKYlgaD_-7ZeyZiDkSwoDlbPRxOedwiEo5puVhlGmnRorjP6XMWIzY_mcBpVXnfnXHWeefWj5qYSGo2bBmEFnfuMc1OX7i25cZwXRQJE4moqFzbpTPaWxhIAd0v42XBRRBceiH6PdvPZLfTxS3MCV0cNP_FG3H-5rcETDf32c-u0bMkcpVuN9XwMMihOF1mKSvg938CWB4MToqj_Wck8oMuR4bSn1pQ64uWSE1pGonjlDF4arWnsaCW5oc-lKULERjKp-UXlpijFYawKvPRJA_tP1JzF1Z3rOTMFHbowQ\" \\\r\n-d '{\r\n\"documentType\": \"VFA\"\r\n}'\r\n==&gt; Resultado:<\/pre>\n<p>HTTP\/2 400<br \/>\ncontent-type: application\/json; charset=utf-8<br \/>\nserver: Microsoft-IIS\/10.0<br \/>\nrequest-context: appId=cid-v1:07e06186-bc8d-4628-9f1a-465b9a0bb54e<br \/>\nx-powered-by: ASP.NET<br \/>\nx-powered-by: ARR\/3.0<br \/>\ndate: Thu, 30 Apr 2020 15:43:37 GMT<br \/>\ncontent-length: 30<\/p>\n<p>{<br \/>\n&#8220;message&#8221;: &#8220;Forbidden&#8221;<br \/>\n}%<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Boa tarde, Tenho estado a desenvolver uma aplica\u00e7\u00e3o com o grant_type &#8220;client_credentials&#8221;, e fiz o seguinte teste com o curl no command line, para perceber o tipo de par\u00e2metros a usar nos &#8216;GET&#8217;s e &#8216;POST&#8217;s \u00e0 API do Jasmin. O que pretendo \u00e9 perceber a raz\u00e3o pela qual o API n\u00e3o me devolve o objeto [&hellip;]<\/p>\n","protected":false},"author":811,"featured_media":0,"template":"","tags":[],"cma_category":[],"cma_difficulty_level":[],"forum-tag":[365],"class_list":["post-12728","cma_thread","type-cma_thread","status-publish","hentry","forum-tag-api-endpoints-en","forum-languages-pt"],"_links":{"self":[{"href":"https:\/\/developers.ila.cegid.com\/en\/wp-json\/wp\/v2\/cma_thread\/12728","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developers.ila.cegid.com\/en\/wp-json\/wp\/v2\/cma_thread"}],"about":[{"href":"https:\/\/developers.ila.cegid.com\/en\/wp-json\/wp\/v2\/types\/cma_thread"}],"author":[{"embeddable":true,"href":"https:\/\/developers.ila.cegid.com\/en\/wp-json\/wp\/v2\/users\/811"}],"wp:attachment":[{"href":"https:\/\/developers.ila.cegid.com\/en\/wp-json\/wp\/v2\/media?parent=12728"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developers.ila.cegid.com\/en\/wp-json\/wp\/v2\/tags?post=12728"},{"taxonomy":"cma_category","embeddable":true,"href":"https:\/\/developers.ila.cegid.com\/en\/wp-json\/wp\/v2\/cma_category?post=12728"},{"taxonomy":"cma_difficulty_level","embeddable":true,"href":"https:\/\/developers.ila.cegid.com\/en\/wp-json\/wp\/v2\/cma_difficulty_level?post=12728"},{"taxonomy":"forum-tag","embeddable":true,"href":"https:\/\/developers.ila.cegid.com\/en\/wp-json\/wp\/v2\/forum-tag?post=12728"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}