2 Replies Latest reply on Jun 22, 2018 8:59 AM by LucasERAS69

    Web API Authentication problems

    LucasERAS69

      Hello,

       

      I've been using the web API sucesfully but I got stumped on CORS problems with POST request. I changed the authentication method but I only made GET request impossible. GET request fail with a 401 error code, which make even basic browsing of the web API impossible since the only thing that is displayed is "Message": "Authorization has been denied for this request.". The API documentation also badly load so it may be a problem with the API itself.

       

      PI help.png

       

      According to the console log, it fails to load the js script so not even the API seems to be able to access itself. Here's a screenshot of my setting. I only have "Anonymous" in my authentication setting.

       

      PI config.png

        • Re: Web API Authentication problems
          gregor

          Hi Lucas,

           

          Did you change anything before running into the issues with POST requests? E.g. did you upgrade your PI Web API instance to a later version? There have been issues with the CSRF Defense which was introduced with PI Web API 2017. Please see KB01650 - CORS and CSRF in PI Web API for details.

           

          Which Authentication method(s) where initially enabled and what changes did you apply?

           

          One thing visible in your screenshot is that AuthenticationMethods attribute does not show as configuration item anymore. The little pencil icon is missing. This was recently identified being the root cause of issues. Please see PI Web API Cross Origin Problem.

            • Re: Web API Authentication problems
              LucasERAS69

              Putting AuthenticationMethods back as a configuration item did the trick. Now, some of my GET request get rejected because of CORS too, but this is another issue and you've given me a link for that. The weird thing is, AuthenticationMethods wasn't a configuration item anymore for a couple of days at least, so it should have blocked me sooner.

               

              Thanks for your help, you solved my problem.