RedHatQE / pylero

Python wrapper for the Polarion WSDL API
https://redhatqe.github.io/pylero/
MIT License
38 stars 25 forks source link

Unable to authenticate with Polarion using a user access token #146

Closed emesika closed 1 year ago

emesika commented 1 year ago

I am trying to run a python script that access Polarion API and I am constantly getting "Invalid Token" on the call I had created a valid access token and it is defined in my pylero conf file which looks like:

[webservice] url=https://polarion.example.com/polarion svn_repo=https://polarion.example.com/repo user=myuser password= token=<my token here , removed for security> default_project=MyProject

I am running this simple python test code :

from pylero.work_item import TestCase
items = TestCase.query("author.id:testuser AND NOT status:inactive",fields=["work_item_id", "author", "title", "project_id"], limit=5, project_id="Polarion")
[logging.info](http://logging.info/)(items)
for item in items:
    tc = TestCase(uri=item.uri)
    [logging.info](http://logging.info/)( "%s:%s:%s:%s" % (tc.work_item_id, tc.title, tc.author, tc.project_id))

$ python3 test.py Invalid Token. Enter Token:

waynesun09 commented 1 year ago

@emesika please also provide the pylero version info, thanks. Also please don't include internal service url and user name info, which I have edited.

emesika commented 1 year ago

pip show pylero Name: pylero Version: 0.0.8 Summary: Python SDK for Polarion Home-page: https://github.com/RedHatQE/pylero Author: pylero Developers Author-email: dno-tools@redhat.com License: MIT Location: Requires: click, suds Required-by:

waynesun09 commented 1 year ago

I can't reproduce with current 0.0.8 version. Where is your .pylero config file, so pylero check home "~" dir and current dir for the config file .pylero, could you check if you've configured both (only one is needed) and any difference with the token value?

Also make sure you are using the right token for the targeted server, like don't use a token from server A to access server B.

emesika commented 1 year ago

pylero.cfg is under ~/.local/lib/python3.9/site-packages/pylero/pylero.cfg Also , I am using the right token for the targeted server

waynesun09 commented 1 year ago

Ok, so the error and prompt for token input only happen when token have been provided in the cfg file but failed to login to the server.

Could you try with manually enter the valid token when the token prompt happen with:

Invalid Token.
Enter Token:

and press enter to see if it could succeed to continue.

emesika commented 1 year ago

Tried it , same result , from some reason it does not accept a token that seems to be valid

emesika commented 1 year ago

I have cloned the pylero code and by debugging it ,it claims that I have no permission to add/edit work items in Polarion:

suds.WebFault: Server raised fault: 'com.polarion.platform.security.PermissionDeniedException: Permission com.polarion.persistence.object.instance.NEW.INSTANCE.key.type.modify denied for user XXXXX in context ContextId[cluster default, context Polarion].'

I am checking that with our Polarion admin and will update soon

emesika commented 1 year ago

Problem was not related to pylero