Using Python Requests to Create a Token for GitHub Enterprise -


i trying create token script has access private repo on github enterprise account. trying this:

username = 'my_username' password = getpass.getpass('github password: ')  payload = {     'note': 'info token' } url = 'https://github.my_company_name.com/api/v3/authorizations' r = requests.post(url, auth=(username, password), data=payload) 

but error:

requests.exceptions.connectionerror: ('connected aborted.', error(10061, 'no connection made because target machine actively refused it')) 

any appreciate, thanks!

import requests bs4 import beautifulsoup url="https://github.com/session"  # define user agent headers={"user-agent":"mozilla/5.0 (windows nt 6.1) applewebkit/537.36 (khtml, gecko) chrome/37.0.2062.120 safari/537.36"}  username="username" password="password"  # create session crawl authenticated sessions s=requests.session()  #update user agent in session created s.headers.update(headers)  #get url using session created r=s.get(url)  #parse webspage find 'authenticity_token'  soup=beautifulsoup(r.content) authenticity_token= soup.find("input",{"name":"authenticity_token"})['value']  # create login data login_data={"authenticity_token":authenticity_token, "login":username, "password":password, "commit":"sign in"}  #now login r=s.post(url, data=login_data)  #test soup=beautifulsoup(r.content) print soup.find(class_="css-truncate-target").text #this should print username 

you can want once logged in :-)

hope helps.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -