【问题标题】:Why am I getting this error in Oauth 2 access token code using PL/SQL?为什么我在使用 PL/SQL 的 Oauth 2 访问令牌代码中出现此错误?
【发布时间】:2020-10-02 16:35:38
【问题描述】:

我可以使用邮递员获取访问令牌,但无法使用 PL/SQL 块。即使我使用相同的客户端 ID 和客户端密码,我也会收到未经授权的回复。请让我知道我做错了什么。我正在研究 oracle 12c。谢谢。

DECLARE

  http_req     UTL_HTTP.REQ;
  http_resp    UTL_HTTP.RESP;
  l_ClientID varchar2(1000) := 'clientid';
  l_ClientSecret varchar2(1000) := 'clientsecret';
  l_AuthResponse UTL_HTTP.RESP;
  l_AuthRaw VARCHAR2 (32767);
  l_AuthReqBody varchar2(2000);
  v_url varchar2(2000) := 'http://someurl/oauth/token';
  l_ClientCredetial VARCHAR2(1000) := l_ClientID || ':' || l_ClientSecret;

BEGIN

   l_AuthReqBody := 'grant_type=client_credentials'|| chr(38) || 'client_id=' || l_ClientID || chr(38) || 'client_secret=' || l_ClientSecret;

   -- Set Oracle Wallet, which works fine

   http_req := utl_http.begin_request(
                   v_url ,
                   'POST',
                   'HTTP/1.1');

  utl_http.set_header (http_req, 'Content-Type','application/x-www-form-urlencoded');

   utl_http.write_text (http_req, l_AuthReqBody);

   l_AuthResponse := utl_http.get_response(http_req);

   utl_http.read_text(l_AuthResponse, l_AuthRaw);
   sp_memo_temp('1 l_AuthRaw: '||l_AuthRaw);

  UTL_HTTP.end_response (l_AuthResponse);
  UTL_HTTP.end_request (http_req);
END;

【问题讨论】:

    标签: oracle authentication plsql oauth-2.0 rest


    【解决方案1】:

    我只需要使用 OAuth 访问 REST Web 服务,并且只需要使用我的令牌 utl_http.set_header(l_http_request, 'Authorization', l_token) 设置一个标头。

    【讨论】:

      猜你喜欢
      • 2017-02-13
      • 2013-02-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-11
      • 2021-04-30
      • 1970-01-01
      相关资源
      最近更新 更多