Forum Stats

  • 3,852,122 Users
  • 2,264,066 Discussions
  • 7,904,967 Comments

Discussions

Getting 401 unauthorised error when accessing custom web service.

Hi,

Can idea about below issue.

I am getting token by using OAuth and also validating the OAuth token.

Fetching the token and validating the token is working fine.

We are configured OAM for this process.

When I send the token in headers to the REST API web services, I get 401 unauthorized error.

10.4.2 401 Unauthorized

The request requires user authentication. The response MUST include a WWW-Authenticate header field (section 14.46) containing a challenge applicable to the requested resource. The client MAY repeat the request with a suitable Authorization header field (section 14.8). If the request already included Authorization credentials, then the 401 response indicates that authorization has been refused for those credentials. If the 401 response contains the same challenge as the prior response, and the user agent has already attempted authentication at least once, then the user SHOULD be presented the entity that was given in the response, since that entity MAY include relevant diagnostic information. HTTP access authentication is explained in section 11.

Answers

  • Richard Napier
    Richard Napier Member Posts: 477 Bronze Trophy
    edited Sep 23, 2022 9:32AM

    Hello

    According to the documentation, the SAML-based OAM authentication is supported only for Oracle Policy Modeling and Oracle Intelligent Advisor Hub interactive users:

    "Note: External authentication is only supported for users that login interactively to Oracle Policy Modeling and Intelligent Advisor Hub."

    " To control access to Intelligent Advisor Determinations API web services and the command line administration tool, use API clients."

    Therefore, it appears that you are trying to do something that is not supported. You are attempting to use OAM SAML to access the REST API. This requires an API Client, not an interactive user.

    You can use an API Client that is managed in Oracle Identity Cloud Service but listed in the Oracle Intelligent Advisor Hub for permissions management. The online documentation references this use case here.

    Regards

  • User_SDLH4
    User_SDLH4 Member Posts: 15 Green Ribbon


    Hi Richard Napier,

    Thanks for your reply,

    I am accessing web services using basic authentication.

    But the issue with OAuth authentication accessing web services.

    1) http://hostname:port/ms_oauth/oauth2/endpoints/oauthservice/tokens

    I am fetching the token from the above API.

    2) I am sending the access token("Authorization ": token) in the header to the web service. I am getting 401 unauthorized error. But instead of sending a token, I am sending ("Authorization ": Basic encoded username: password) to the web service I got status code 200 and also got the data.

    3) All the above processes are done from the front-end language (Javascript).


    Can you please let me know if I miss anything?


    Thanks,

  • Richard Napier
    Richard Napier Member Posts: 477 Bronze Trophy

    Hi

    Which Oracle Intelligent Advisor Web Service are you attempting to access. Please give an example (Assess, Batch Assess, Admin REST API, Connector SOAP API etc...)

    Thanks

  • User_SDLH4
    User_SDLH4 Member Posts: 15 Green Ribbon


    All the OAuth setup is configured in OAM.

  • Richard Napier
    Richard Napier Member Posts: 477 Bronze Trophy

    Hi

    could you please specify which oracle intelligent advisor service you are attempting to access?

    nothing in your question so far allows us to see the relationship with Oracle Intelligent Advisor and this is the Oracle Intelligent Advisor forum.

    thanks

  • User_SDLH4
    User_SDLH4 Member Posts: 15 Green Ribbon


    Hi,

    I am a front-end developer. Could you please tell me what is oracle intelligent advisor service?


    thanks,

  • Richard Napier
    Richard Napier Member Posts: 477 Bronze Trophy

    Oracle Intelligent Advisor is a decision automation platform with natural language innovative natural language modelling.

    Google can tell you lots more about this excellent product.

    However I believe that to get an answer to your questions it would be more appropriate to ask your questions in another forum.

    R

  • User_SDLH4
    User_SDLH4 Member Posts: 15 Green Ribbon


    How can I access the Web service by using an access token?

  • Richard Napier
    Richard Napier Member Posts: 477 Bronze Trophy
    edited 7:07AM

    Hi

    In my previous message, there was a link explaining how to set up an API client, either directly in Oracle Intelligent Advisor or using Oracle Identity Cloud Service.

    Once you have fulfilled those prerequisites you can use the API Client /auth url to generate a token and use the token to make calls to the services.

    Given that there are a variety of services performing different tasks within Oracle Intelligent Advisor, it is important for you to understand which service you are using and why.

    More information about the services can be found in the documentation here for example https://docs.oracle.com/en/cloud/saas/b2c-service/22c/opawx/index.html

    R