Forum Stats

  • 3,768,190 Users
  • 2,252,758 Discussions


OAuth token - 401 Unauthorized



  • thatJeffSmith-Oracle
    thatJeffSmith-Oracle Distinguished Product Manager Posts: 8,057 Employee

    Basic Auth - you're going to be passing the username AND password on every single request, please please please at least ensure you're ALWAYS in HTTPS.

    It would be much preferable to sort out your OAuth2 workflow issues and use that.

  • Danny*D201
    Danny*D201 Member Posts: 114 Bronze Badge

    Thanks for the advice Jeff, yes to https, definitely.

    I was just hoping to provide some clue for OP and others looking at this post to move pass the error without OAuth in the mix.

    Will invest in setting up OAuth in production systems. Thanks.

  • Paavo
    Paavo Member Posts: 675 Silver Badge

    FYI the example provided works for vanilla ords setup without apex. It is perhaps good idea to enable _sdw sqldeveloper web (db actions). If it works then it is very likely your rest service will work as well.

    IF there is somekind of frontend www-server for apex setup, then you need to bypass it if it is doing authentication before letting in to the url in question.

    % curl -i -k --user clientidgoeshere:clientsecretgoeshere --data "grant_type=client_credentials" https://fqdn/ordswarrenamedforapi/yourenabledschemapath/oauth/token > oauth2_token.txt
    % echo "Authorization: Bearer " | tr -d "\n" > header-auth.txt
    % cat oauth2_token.txt | grep -Eo '"access_token":(\d*?,|.*?[^\\]",)' |awk -F':' '{print $2}' | sed -e 's/",//' |sed -e 's/"//' >> header-auth.txt
    % cat header-auth.txt
    Authorization: Bearer youroauth2token
    % curl -vvv -i -k -H @header-auth.txt https://fqdn/ordswarrenamedforapi/yourenabledschemapath/api-v1/testing/headers

    you might want to fix curl ca bundle:

    hmm what was the ords oauth2 revoke token trick :) ?

    rgrds Paavo

  • Paavo
    Paavo Member Posts: 675 Silver Badge

    Thanx @thatJeffSmith-Oracle about the hint of getting oauth2 bearer token or even example curl for getting oauth2 token. It really rox, see why it is good to get the _sdw working.

    rgrds Paavo