Uploaded image for project: 'Kogito'
  1. Kogito
  2. KOGITO-6587

Authentication not working with secure openapi operation

XMLWordPrintable

    • 2022 Week 08-10 (from Feb 21), 2022 Week 14-16 (from Apr 4), 2022 Week 17-19 (from Apr 25)

      When invoking a request to a secure openapi operation the request receives and authentication error even though the authentication details are configured correctly in the application.properties file.

      The scenario is that I am trying to access the github.com /user/emails path which requires the user to be authenticated.

      I have created a personal access token (PAT) that gives me access to do `/user/emails`. I can call that using curl from my macbook with the PAT specified  but when I try and invoke that from within a sw.yaml, it always seems to give me an authentication error. 
      ```
      2022-01-19 17:21:19,384 DEBUG [org.apa.htt.imp.exe.MainClientExec] (executor-thread-0) Executing request GET /user/emails HTTP/1.1
      2022-01-19 17:21:19,384 DEBUG [org.apa.htt.headers] (executor-thread-0) http-outgoing-4 >> GET /user/emails HTTP/1.1
      2022-01-19 17:21:19,384 DEBUG [org.apa.htt.headers] (executor-thread-0) http-outgoing-4 >> Accept: application/json
      2022-01-19 17:21:19,384 DEBUG [org.apa.htt.headers] (executor-thread-0) http-outgoing-4 >> Cookie: User-Agent=OpenAPI-Generator/1.1.4/java
      2022-01-19 17:21:19,385 DEBUG [org.apa.htt.headers] (executor-thread-0) http-outgoing-4 >> kogitoprocid: github2
      2022-01-19 17:21:19,385 DEBUG [org.apa.htt.headers] (executor-thread-0) http-outgoing-4 >> kogitoprocinstanceid: 285d0985-085d-41cd-bdb8-d21802dbf7e3
      2022-01-19 17:21:19,385 DEBUG [org.apa.htt.headers] (executor-thread-0) http-outgoing-4 >> kogitoprocist: 1
      2022-01-19 17:21:19,385 DEBUG [org.apa.htt.headers] (executor-thread-0) http-outgoing-4 >> User-Agent: OpenAPI-Generator/1.1.4/java
      2022-01-19 17:21:19,385 DEBUG [org.apa.htt.headers] (executor-thread-0) http-outgoing-4 >> Host: api.github.com
      2022-01-19 17:21:19,385 DEBUG [org.apa.htt.headers] (executor-thread-0) http-outgoing-4 >> Connection: Keep-Alive
      2022-01-19 17:21:19,385 DEBUG [org.apa.htt.wire] (executor-thread-0) http-outgoing-4 >> "GET /user/emails HTTP/1.1[\r][\n]"
      2022-01-19 17:21:19,385 DEBUG [org.apa.htt.wire] (executor-thread-0) http-outgoing-4 >> "Accept: application/json[\r][\n]"
      2022-01-19 17:21:19,385 DEBUG [org.apa.htt.wire] (executor-thread-0) http-outgoing-4 >> "Cookie: User-Agent=OpenAPI-Generator/1.1.4/java[\r][\n]"
      2022-01-19 17:21:19,385 DEBUG [org.apa.htt.wire] (executor-thread-0) http-outgoing-4 >> "kogitoprocid: github2[\r][\n]"
      2022-01-19 17:21:19,385 DEBUG [org.apa.htt.wire] (executor-thread-0) http-outgoing-4 >> "kogitoprocinstanceid: 285d0985-085d-41cd-bdb8-d21802dbf7e3[\r][\n]"
      2022-01-19 17:21:19,386 DEBUG [org.apa.htt.wire] (executor-thread-0) http-outgoing-4 >> "kogitoprocist: 1[\r][\n]"
      2022-01-19 17:21:19,386 DEBUG [org.apa.htt.wire] (executor-thread-0) http-outgoing-4 >> "User-Agent: OpenAPI-Generator/1.1.4/java[\r][\n]"
      2022-01-19 17:21:19,386 DEBUG [org.apa.htt.wire] (executor-thread-0) http-outgoing-4 >> "Host: api.github.com[\r][\n]"
      2022-01-19 17:21:19,386 DEBUG [org.apa.htt.wire] (executor-thread-0) http-outgoing-4 >> "Connection: Keep-Alive[\r][\n]"
      2022-01-19 17:21:19,386 DEBUG [org.apa.htt.wire] (executor-thread-0) http-outgoing-4 >> "[\r][\n]"
      2022-01-19 17:21:19,512 DEBUG [org.apa.htt.wire] (executor-thread-0) http-outgoing-4 << "HTTP/1.1 401 Unauthorized[\r][\n]"
      ```
      I have specified the properties in the application.properties file:
      ```
      org.kogito.openapi.client.api.github.com.username=<my usrid>
      org.kogito.openapi.client.api.github.com.password=<my PAT>
      ```
      but this still seems to say that the request is unauthorised. 

              rhn-support-zanini Ricardo Zanini
              groeges Steven Groeger (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: