I am confused about utl_http and oauth authentication with shopware 6. I undestand I have to obtain a token, which has to be used in futher requests. With all efforts I am getting the answer: "The authorization grant type is not supported by the authorization server".
There is tons of info on this issue but very little with utl_http - so i wonder if utl_http is comaptible with shopware anyway. Does anybody have a hint for me? thanks in advance!
l_req UTL_HTTP.req;
l_resp UTL_HTTP.resp;
l_text VARCHAR2(32767);
begin
-- setting the Wallet works - ACL is also set up properly!
utl_http.set_wallet('[wallet_file]','[wallet_pwaasword]');
l_req := UTL_HTTP.begin_request([my-shopware-url.de]/api/oauth/token], 'POST', 'HTTP/1.1');
utl_http.set_header(l_req, 'content-type', 'application/json');
utl_http.set_header(l_req, 'Accept', 'application/json');
utl_http.write_text(l_req,'{
"grant_type": "client_credentials",
"client_id": "[my-client-id]",
"client_secret": "[my-client-secret]"
}');
l_resp := utl_http.get_response(l_req);
utl_http.read_text(l_resp, l_text, 32766);
DBMS_OUTPUT.put_line (l_text); -- "The authorization grant type is not supported by the authorization server".
-- once the token is obtained, I would set the token in the header for the next request
utl_http.set_header(l_req, 'sw-access-key', [TOKEN]);
utl_http.write_text(l_req,'[REQUEST-BODY]');
l_resp := utl_http.get_response(l_req);
utl_http.end_response(l_resp);
end;