conn testuser1/testuser1@//localhost:1521/freepdb1
set serveroutput on
declare
l_client_cred ords_types.t_client_credentials;
begin
l_client_cred := ords_security.register_client(
p_name => 'emp_client',
p_grant_type => 'authorization_code',
p_description => 'My Company Limited',
p_client_secret => ords_types.oauth_client_secret(p_secret => '07_3O7qs859x_1Vpkq0QOQ..'),
p_redirect_uri => 'https://localhost:8443/ords/hr/redirect',
p_support_email => '[email protected]',
p_support_uri => 'https://localhost:8443/ords/hr/support',
p_privilege_names => 'emp_priv'
);
commit;
dbms_output.put_line('CLIENT_ID : ' || l_client_cred.client_key.client_id);
dbms_output.put_line('CLIENT_SECRET : ' || l_client_cred.client_secret.secret);
END;
/
CLIENT_ID : YJVRN1E6OZd_13zKg6-wnw..
CLIENT_SECRET : 07_3O7qs859x_1Vpkq0QOQ..
PL/SQL procedure successfully completed.
SQL>
-- Display client details.
column name format a20
select id, name, client_id, client_secret
from user_ords_clients;
ID NAME CLIENT_ID CLIENT_SECRET
---------- -------------------- -------------------------------- --------------------
10204 emp_client YJVRN1E6OZd_13zKg6-wnw.. ********
SQL>
CLIENT_ID : YJVRN1E6OZd_13zKg6-wnw..
State : 3668D7A713E93372E0406A38A8C02171
URL : https://localhost:8443/ords/hr/oauth/auth?response_type=code&client_id={client_id}&state={state}
https://localhost:8443/ords/hr/oauth/auth?response_type=code&client_id=
YJVRN1E6OZd_13zKg6-wnw..
&state=
3668D7A713E93372E0406A38A8C02171
https://localhost:8443/ords/hr/redirect?code=
5oxUYSRh321gYD6ruevoNQ
&state=
3668D7A713E93372E0406A38A8C02171
CLIENT_ID : YJVRN1E6OZd_13zKg6-wnw..
CLIENT_SECRET : 07_3O7qs859x_1Vpkq0QOQ..
User : CLIENT_ID:CLIENT_SECRET
Data : grant_type=authorization_code&code={authorization-code}
URL : https://localhost:8443/ords/hr/oauth/token
$
curl -i -k --user YJVRN1E6OZd_13zKg6-wnw..:07_3O7qs859x_1Vpkq0QOQ.. --data "grant_type=authorization_code&code=5oxUYSRh321gYD6ruevoNQ" https://localhost:8443/ords/hr/oauth/token
HTTP/1.1 200
Strict-Transport-Security: max-age=31536000;includeSubDomains
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Cache-Control: no-cache, no-store, max-age=0
X-Frame-Options: SAMEORIGIN
vary: accept-encoding
Content-Type: application/json
Transfer-Encoding: chunked
Date: Fri, 20 Jun 2025 16:31:26 GMT
{"access_token":"n93iAmMuOVALoYuM29cvJQ","token_type":"bearer","expires_in":3600,"refresh_token":"vO07ZsWoFRmN540ZNAbSKA"}
$
$
curl -i -k -H"Authorization: Bearer n93iAmMuOVALoYuM29cvJQ" https://localhost:8443/ords/hr/employees/7788
HTTP/1.1 200
Strict-Transport-Security: max-age=31536000;includeSubDomains
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
ETag: "bK1/oAjORtTe2J2PZwghyQT5Czyzr/eE8brkgPwsGIVlPc63QI+dqzTA7wGVOc3/Sw26RJYRbRtltQRHOQs1CQ=="
Cache-Control: max-age=0
Expires: Fri, 20 Jun 2025 16:33:58 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Date: Fri, 20 Jun 2025 16:33:58 GMT
{"empno":7788,"ename":"SCOTT","job":"ANALYST","mgr":7566,"hiredate":"1987-04-19T00:00:00Z","sal":3000,
"comm":null,"deptno":20,"links":[{"rel":"self","href":"https://localhost:8443/ords/hr/employees/7788"},
{"rel":"edit","href":"https://localhost:8443/ords/hr/employees/7788"},
{"rel":"describedby","href":"https://localhost:8443/ords/hr/metadata-catalog/employees/item"},
{"rel":"collection","href":"https://localhost:8443/ords/hr/employees/"}]}
$