Guest User

Untitled

a guest
Oct 18th, 2021
29
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DECLARE
  2.  
  3.   l_result          clob;
  4.   l_client_id       VARCHAR2(300) := 'client_id_hidden';
  5.   l_client_secret   VARCHAR2(300) := 'client_secre_hidden';
  6.  
  7.   FUNCTION base64encode(t IN VARCHAR2) RETURN VARCHAR2 IS
  8.   BEGIN
  9.     RETURN TRANSLATE(UTL_RAW.cast_to_varchar2(UTL_ENCODE.base64_encode(UTL_RAW.cast_to_raw(t))), 'd'||CHR(10)||CHR(13), 'd');
  10.   END;
  11.  
  12. BEGIN
  13.  
  14.   apex_web_service.g_request_headers.DELETE();
  15.  
  16.   apex_web_service.g_request_headers(1).name  := 'authorization';
  17.   apex_web_service.g_request_headers(1).VALUE := 'Basic '|| base64encode(l_client_id||':'||l_client_secret);
  18.   apex_web_service.g_request_headers(2).name  := 'Content-Type';
  19.   apex_web_service.g_request_headers(2).VALUE := 'application/x-www-form-urlencoded';
  20.    
  21.   l_result := apex_web_service.make_rest_request(
  22.     p_url            => 'http://localhost/identity-xero-api-proxy/connect/token'
  23.    ,p_http_method    => 'POST'
  24.    ,p_body           => '{"grant_type":"client_credentials"
  25.                         ,"scope":"accounting.transactions accounting.contacts assets files"
  26.                         }'
  27.    );
  28.  
  29.   DBMS_OUTPUT.put_line(l_result);
  30.  
  31. END;
RAW Paste Data