Search code examples
pythongithub-apigithub-enterprise

Unable to call github APIs given username and password


I'm trying to call Github APIs to the Github Enterprise Server in the company that I work for. The API calls works when I use personal access token, but every time I used user name and password, I'm getting an HTTP 401 error message "Must authenticate to use this API".

I tried using the following tools:

  • curl

Sample call:

curl --proxy $PROXY -i --user "xx-xx" https://github.xxx.xxx.com/api/v3/users

Sample code:

gh = Github('my-user', password='....', base_url='https://github.xxx.xxx.com/api/v3/users')

Sample code

r = requests.get('https://github.xxx.xxx.com', auth=('my-user','....'), proxies=proxyDict) 

Doesn't work if I use either HTTPBasicAuth or HTTPDigestAuth

The company github website is authenticated via SAML, so I'm wondering if this is SAML related issue.


Solution

  • Github does not allow http/https authentications. (same for bitbucket and gitlab). I learnt it hard-way.

    You may want to use ssh public key based authentication.