MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / get_auth_token

Function get_auth_token

tools/gh_api.py:34–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32
33token = None
34def get_auth_token():
35 global token
36
37 if token is not None:
38 return token
39
40 try:
41 with open(os.path.join(os.path.expanduser('~'), '.ghoauth')) as f:
42 token, = f
43 return token
44 except Exception:
45 pass
46
47 import keyring
48 token = keyring.get_password('github', fake_username)
49 if token is not None:
50 return token
51
52 print("Please enter your github username and password. These are not "
53 "stored, only used to get an oAuth token. You can revoke this at "
54 "any time on GitHub.")
55 user = input("Username: ")
56 pw = getpass.getpass("Password: ")
57
58 auth_request = {
59 "scopes": [
60 "public_repo",
61 "gist"
62 ],
63 "note": "IPython tools",
64 "note_url": "https://github.com/ipython/ipython/tree/master/tools",
65 }
66 response = requests.post('https://api.github.com/authorizations',
67 auth=(user, pw), data=json.dumps(auth_request))
68 response.raise_for_status()
69 token = json.loads(response.text)['token']
70 keyring.set_password('github', fake_username, token)
71 return token
72
73def make_auth_header():
74 return {'Authorization': 'token ' + get_auth_token().replace("\n","")}

Callers 1

make_auth_headerFunction · 0.85

Calls 1

joinMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…