how to login gerrit by python

551 views
Skip to first unread message

陈翰林

unread,
Feb 20, 2022, 10:04:46 PM2/20/22
to Repo and Gerrit Discussion
hi all:
  my version is 2.14.6 and can't upgrade it,now i wan't login it by python and do other operations,but i can't login with python module like requests,pygerrit2 and python-gerrit-api

 i try to with scripts :
1.
    from pygerrit2 import GerritRestAPI,HTTPBasicAuth
    auth=HTTPBasicAuth(user,passwd)
    rest = GerritRestAPI(url='http://mygerrit:8090', auth=auth)

2.
   from gerrit import GerritClient client = GerritClient(base_url="http://mygerrit:8090", username='******', password='xxxxx')
3.
   import requests
   data={'username':xxx,'password':xxx}
   requests.post(url,data=data)   

all of them has same error info:
    requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url:

somebody told version 2.14 has anther auth way,so who know how to login success,please let me know ,thanks very much.

Sun King

unread,
Feb 22, 2022, 8:32:05 PM2/22/22
to Repo and Gerrit Discussion
I think , python-gerrit client is a easier way to achieve that. 
Message has been deleted
Message has been deleted

陈翰林

unread,
Feb 22, 2022, 10:09:57 PM2/22/22
to Repo and Gerrit Discussion
@king
thanks,i got it

Wo Lf

unread,
Feb 25, 2022, 1:15:00 PM2/25/22
to '陈翰林' via Repo and Gerrit Discussion
To:

Sent via t.me/gmailbot

2022-02-20 19:04 (GMT-08:00), "'陈翰林' via Repo and Gerrit Discussion"
> --
> --
> To unsubscribe, email repo-discuss...@googlegroups.com
> More info at http://groups.google.com/group/repo-discuss?hl=en
> ---
> You received this message because you are subscribed to the Google Groups "Repo
> and Gerrit Discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to repo-discuss...@googlegroups.com.
> To view this discussion on the web visit <a
> href="https://groups.google.com/d/msgid/repo-discuss/eeaa1ebd-f64b-4e58-befa-d1c16e525a86n%40googlegroups.com?utm_medium=email&utm_source=footer">https://groups.google.com/d/msgid/repo-discuss/eeaa1ebd-f64b-4e58-befa-d1c16e525a86n%40googlegroups.com</a>.
>
Reply all
Reply to author
Forward
0 new messages