It's all about the answers!

Ask a question

how to resolve the authentication issue while getting data with python request ?


Ghati R (111) | asked Apr 11, 6:26 a.m.
I am making an authentication request with Python's requests package, 
to fetch Test Plan details and further processing, from MY_PROJECT.
Right in the beginning of it I am facing the authorization issue, despite getting
a 200 status.

Details : 
1. URL = https://MY_PROJECT/qm/service/com.ibm.rqm.integration.service.IIntegrationService/resources/
2. response = requests.get(URL, auth = (MY_UN, MY_PW), verify=False) 3. I have verified the browser to have Java - Auto Enabled 4. Experimented with passing header, but to no avail :
_headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/'
'537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'
}
5. Experimented with Proxies as well, and it seems to be fine on that front.
For the above request,
I am getting notably these texts : 
1. <Javascript is either disabled or not available in your Browser> ... 
2. <net.jazz.ajax.ui.PlatformUI.createAndRunWorkbench("net.jazz.web.app.authrequired")>

Requesting if there is someway in which I can solve this issue ?
pasting a sample output for reference


Output - 
<!DOCTYPE html>
<body class="claro"><noscript><div id="net-jazz-ajax-NoScriptMessage">Javascript is either disabled or not available in your Browser</div></noscript>
<div id="net-jazz-ajax-InitialLoadMessage">Loading...</div>
<div id="net-jazz-ajax-WorkbenchRoot"></div>
.
.
.<script type="text/javascript">
    /* <![CDATA[ */
        require(["dojo/ready", "dojo/parser", "dijit/registry", "dijit/Dialog"], function(ready, parser, registry){
             ready(function(){
                net.jazz.ajax.ui.PlatformUI.createAndRunWorkbench("net.jazz.web.app.authrequired");
             });
        });
    /* ]]> */
/script>
</body>
</html>
<200>
Process finished with exit code 0

One answer



permanent link
Ralph Schoon (63.2k33646) | answered Apr 11, 7:23 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Apr 11, 8:44 a.m.

Basically, you are not authenticated and you need a session.

There are different authentication schemas dependent on how your server is configured. Please see: https://rsjazz.wordpress.com/2021/10/15/elm-authentication/ which is based on https://jazz.net/wiki/bin/view/Main/NativeClientAuthentication .




Comments
Ghati R commented Apr 11, 9:16 a.m.

Thank you Ralph for the response ! I 'll check out that link.


Ghati R commented Apr 11, 2:16 p.m. | edited Apr 11, 2:19 p.m.

Hi Ralph, I followed the NativeClientAuthentication link and the authentication steps defined there. I see that my schema is " FORM Challenge", as I get the GET status of < 200 > for the initial request.
However, after sequentially proceeding to Analysis of POST Status, I get :
1. Status = 200
2. header [  X-com-ibm-team-repository-web-auth-msg ]  = authrequired . 
Which suggests that the Authentication is successful; and I replayed my initial GET URL request many times (as suggested in the NCA link)

But Still, I am getting the Output as described in my original Post.

Requesting if you could help me out here.
With Thanks.
PS : I also did my Approach as outlined by the Blog wrt python functions and such.


Ralph Schoon commented Apr 11, 3:28 p.m. | edited Apr 11, 4:29 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I am getting tired of these answers "I do it right, but the response is unexpected".

The header
[  X-com-ibm-team-repository-web-auth-msg ]  = authrequired 

indicates you are not authenticated. The header says "authentication required". Status 302 and 200 indicate a possible form authentication is needed. You do not perform a form authentication either, for all I can tell. The URI is a different one the request body also The response data also shows unauthenticated. Also, you need a session.

My code works, look what it does and take it or leave it. I have used it for a long time now. I am pretty sure I know how this works.

I will not continue discussing this here. To be sure, you can also use Firefox, install RESTClient. Open the target application in the browser and authenticate.  Then GET your link. If that works you know you did your authentication wrong.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.