Skip to content

Commit 0b49e41

Browse files
authored
Merge pull request #138 from sommersoft/git_token_fix
Switch To New GitHub API Authentication Scheme
2 parents b3d7359 + 8370e37 commit 0b49e41

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ Applying Patches To All CircuitPython Libraries
115115
================================================
116116
To apply a patch to all CircuitPython libraries (only guaranteed for files shared
117117
among all libraries, such as those included in the cookiecutter (e.g. README.rst,
118-
.travis.yml, etc), do the following:
118+
etc), do the following:
119119

120120
1. Apply your update(s) to any library as normal, using ``git commit``. It is recommended to
121121
give a short, detailed description of the patch. This description will be used by the next

adabot/github_requests.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
import time
3636
import traceback
3737

38+
from base64 import b64encode
39+
3840
TIMEOUT = 60
3941

4042
def _fix_url(url):
@@ -52,11 +54,12 @@ def _fix_kwargs(kwargs):
5254
else:
5355
kwargs["headers"] = {"Accept": "application/vnd.github.hellcat-preview+json"}
5456
if "ADABOT_GITHUB_ACCESS_TOKEN" in os.environ and "auth" not in kwargs:
57+
user = os.environ.get("ADABOT_GITHUB_USER", "")
5558
access_token = os.environ["ADABOT_GITHUB_ACCESS_TOKEN"]
56-
if "params" in kwargs:
57-
kwargs["params"]["access_token"] = access_token
58-
else:
59-
kwargs["params"] = {"access_token": access_token}
59+
basic_encoded = b64encode(str(user + ":" + access_token).encode()).decode()
60+
auth_header = "Basic {}".format(basic_encoded)
61+
62+
kwargs["headers"]["Authorization"] = auth_header
6063

6164
return kwargs
6265

template-env.sh

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
# https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/
33
# KEEP THIS TOKEN SECRET AND SAFE! Anyone with access to the token has FULL CONTROL of your GitHub account!
44
export ADABOT_GITHUB_ACCESS_TOKEN=<your personal access token>
5-
# Go here to generate a travis access token:
6-
# https://blog.travis-ci.com/2013-01-28-token-token-token
7-
# Note you want the 'Travis Token' (third option) and NOT the 'Access Token'. Use the ruby gem mentioned to generate.
8-
# KEEP THIS TOKEN SECRET AND SAFE! Although it is unclear what access the token grants (Travis seems to imply it's less
9-
# risk to share), always assume secrets like these are dangerous to expose to others.
10-
# Note 2: since all CircuitPython repositories have been migragted to travis-ci.com, be sure to use an access token
11-
# from '.com', not '.org'. These tokens are not interchangeable.
12-
export ADABOT_TRAVIS_ACCESS_TOKEN=<your Travis token>
5+
6+
# This is the username associated with the access token.
7+
export ADABOT_GITHUB_USER=<username>

0 commit comments

Comments
 (0)