{"id":1877,"date":"2024-09-20T17:21:34","date_gmt":"2024-09-20T16:21:34","guid":{"rendered":"https:\/\/france.magicsoftware.com\/blog\/?p=1877"},"modified":"2025-06-05T07:32:08","modified_gmt":"2025-06-05T06:32:08","slug":"magento-magic-xpi","status":"publish","type":"post","link":"https:\/\/france.magicsoftware.com\/blog\/magic-xpi\/magento-magic-xpi\/","title":{"rendered":"Magento &#8211; Magic xpi"},"content":{"rendered":"\n<p class=\"has-medium-font-size\"><strong>Goal : Generate Magento signature for OAuth1 and call Magento REST API with Magic xpi<\/strong><\/p>\n\n\n\n<p>1\/ Prerequisites :<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Get your consumerKey, consumerSecret, tokenSecret and tokenValue from you Magento Admin<\/li>\n\n\n\n<li>Some Magic xpa knowledge <\/li>\n<\/ul>\n\n\n\n<p>2\/ Check with Postman that your Access REST API is working<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"511\" src=\"https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN2-1024x511.png\" alt=\"\" class=\"wp-image-1884\" style=\"width:565px;height:auto\" srcset=\"https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN2-1024x511.png 1024w, https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN2-300x150.png 300w, https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN2-768x383.png 768w, https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN2.png 1396w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Set \u00ab\u00a0Version\u00a0\u00bb with 1.0 and tick \u00ab\u00a0Encode the parameters &#8230;\u00a0\u00bb, Leave other parameters empty<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"573\" src=\"https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN3-1024x573.png\" alt=\"\" class=\"wp-image-1887\" style=\"width:621px;height:auto\" srcset=\"https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN3-1024x573.png 1024w, https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN3-300x168.png 300w, https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN3-768x430.png 768w, https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN3.png 1124w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>2\/ Generate the Magento signature with a Magic xpi User Function<\/p>\n\n\n\n<p>Open your Magic xpa Studio and create a new project , name it \u00ab\u00a0userfunctions\u00a0\u00bb<\/p>\n\n\n\n<p>Define in the Main a new function and name it \u00ab\u00a0GetMagentoSignature\u00a0\u00bb or whatever (Function scope must be set to global).<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"87\" src=\"https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN4-1024x87.png\" alt=\"\" class=\"wp-image-1894\" srcset=\"https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN4-1024x87.png 1024w, https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN4-300x25.png 300w, https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN4-768x65.png 768w, https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN4.png 1218w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Generate your HMAC256 within this function and generate your ecf file in \u00ab\u00a0&lt;Magic xpi directory&gt;Runtime\\User resources\u00a0\u00bb directory.<\/p>\n\n\n\n<p>In my case, i have used, a dotnet snippet inside the function (<strong>Invoke .NET<\/strong>) and the website <a href=\"https:\/\/lti.tools\/oauth\/\">lti.tools\/oauth\/<\/a> to understand the OAuth1 algorithm<\/p>\n\n\n\n<p>(*) In other to get the information on how to generate Magento OAuth1 signature, please check the link below (\u00ab\u00a0The OAuth Signature\u00a0\u00bb)<\/p>\n\n\n\n<p><a href=\"https:\/\/developer.adobe.com\/commerce\/webapi\/get-started\/authentication\/gs-authentication-oauth\/#access-the-web-apis\">https:\/\/developer.adobe.com\/commerce\/webapi\/get-started\/authentication\/gs-authentication-oauth\/#access-the-web-apis<\/a><\/p>\n\n\n\n<p>The idea is that my function is returning a string formatted like below<\/p>\n\n\n\n<p>OAuth oauth_consumer_key=\u00a0\u00bb\u00a0\u00bb,oauth_token=\u00a0\u00bb\u00a0\u00bb,oauth_signature_method=\u00a0\u00bbHMAC-SHA256&Prime;,oauth_timestamp=\u00a0\u00bb\u00a0\u00bb+<strong>timeStamp<\/strong>+\u00a0\u00bb\u00a0\u00bb,oauth_nonce=\u00a0\u00bb\u00a0\u00bb+<strong>nonce<\/strong>+\u00a0\u00bb\u00a0\u00bb,oauth_version=\u00a0\u00bb1.0&Prime;,oauth_signature=\u00a0\u00bb\u00a0\u00bb+<strong>encodedsignature<\/strong>+\u00a0\u00bb\u00a0\u00bb<\/p>\n\n\n\n<p>(*) variables <strong>timestamp, nonce , encodedsignature<\/strong> are calculated in the code of the function.<\/p>\n\n\n\n<p>3\/ Add in your FunctionDescription.en.xml file (\u00ab\u00a0&lt;Magic xpi directory>\\Studio), the xml portion below at the end of the file<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"686\" height=\"541\" src=\"https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN5.png\" alt=\"\" class=\"wp-image-1899\" style=\"width:441px;height:auto\" srcset=\"https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN5.png 686w, https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN5-300x237.png 300w\" sizes=\"auto, (max-width: 686px) 100vw, 686px\" \/><\/figure>\n\n\n\n<p>4\/ Create a Magic xpi project and create a REST Client resource<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"359\" src=\"https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN6-1024x359.png\" alt=\"\" class=\"wp-image-1902\" style=\"width:684px;height:auto\" srcset=\"https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN6-1024x359.png 1024w, https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN6-300x105.png 300w, https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN6-768x269.png 768w, https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN6.png 1281w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>5\/ Create a new flow<\/p>\n\n\n\n<p>Define 2 fow variables (F.SignatureEncoded (alpha unlimited) and F.Url (alpha unlimited).<\/p>\n\n\n\n<p>Drag and drop a Flow Data Connector and update the 2 flow variables like below<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"318\" src=\"https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN7-1024x318.png\" alt=\"\" class=\"wp-image-1905\" style=\"width:723px;height:auto\" srcset=\"https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN7-1024x318.png 1024w, https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN7-300x93.png 300w, https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN7-768x238.png 768w, https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN7.png 1282w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>6\/ Drag &amp; Drop a REST Client connector after this step and configure it like below<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"583\" src=\"https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN8-1024x583.png\" alt=\"\" class=\"wp-image-1914\" style=\"width:501px;height:auto\" srcset=\"https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN8-1024x583.png 1024w, https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN8-300x171.png 300w, https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN8-768x437.png 768w, https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN8.png 1119w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>7\/ Execute the flow in Debug mode<\/p>\n\n\n\n<p>You should see the Authorization header in the Flow variable F.SignatureEncoded  with the oauth_signature generated<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"406\" src=\"https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN9-1024x406.png\" alt=\"\" class=\"wp-image-1916\" style=\"width:651px;height:auto\" srcset=\"https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN9-1024x406.png 1024w, https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN9-300x119.png 300w, https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN9-768x305.png 768w, https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN9.png 1434w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"452\" src=\"https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN10-1024x452.png\" alt=\"\" class=\"wp-image-1918\" style=\"width:709px;height:auto\" srcset=\"https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN10-1024x452.png 1024w, https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN10-300x133.png 300w, https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN10-768x339.png 768w, https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN10.png 1435w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>You should receive status code 200 with OK and the JSON result of your query.<\/p>\n\n\n\n<p>8\/ <a href=\"https:\/\/developer.adobe.com\/commerce\/webapi\/rest\/quick-reference\/\" title=\"\">https:\/\/developer.adobe.com\/commerce\/webapi\/rest\/quick-reference\/<\/a><\/p>\n\n\n\n<p>(*) In other to get the different Json schemas please check with the link above<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Goal : Generate Magento signature for OAuth1 and call Magento REST API with Magic xpi 1\/ Prerequisites : 2\/ Check with Postman that your Access REST API is working Set \u00ab\u00a0Version\u00a0\u00bb with 1.0 and tick \u00ab\u00a0Encode the parameters &#8230;\u00a0\u00bb, Leave other parameters empty 2\/ Generate the Magento signature with a Magic xpi User Function Open [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1879,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[56,4,65],"tags":[57],"class_list":["post-1877","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-magento","category-magic-xpi","category-retail","tag-magento"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/france.magicsoftware.com\/blog\/wp-content\/uploads\/2024\/09\/MAGEN1.png","_links":{"self":[{"href":"https:\/\/france.magicsoftware.com\/blog\/wp-json\/wp\/v2\/posts\/1877","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/france.magicsoftware.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/france.magicsoftware.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/france.magicsoftware.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/france.magicsoftware.com\/blog\/wp-json\/wp\/v2\/comments?post=1877"}],"version-history":[{"count":42,"href":"https:\/\/france.magicsoftware.com\/blog\/wp-json\/wp\/v2\/posts\/1877\/revisions"}],"predecessor-version":[{"id":3061,"href":"https:\/\/france.magicsoftware.com\/blog\/wp-json\/wp\/v2\/posts\/1877\/revisions\/3061"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/france.magicsoftware.com\/blog\/wp-json\/wp\/v2\/media\/1879"}],"wp:attachment":[{"href":"https:\/\/france.magicsoftware.com\/blog\/wp-json\/wp\/v2\/media?parent=1877"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/france.magicsoftware.com\/blog\/wp-json\/wp\/v2\/categories?post=1877"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/france.magicsoftware.com\/blog\/wp-json\/wp\/v2\/tags?post=1877"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}