class: center, middle, inverse, title-slide # Personal Authentication Tokens ## The GitHub PAT ### Colin Gillespie (
@csgillespie
) --- layout:true layout: true <div class="jr-header"> <img class="logo" src="assets/white_logo_full.png"/> <span class="social"><table><tr><td><img src="assets/twitter.gif"/></td><td> @jumping_uk</td></tr></table></span> </div> <div class="jr-footer"><span>© 2019 Jumping Rivers (jumpingrivers.com)</span><div>http://bit.ly/user2019-git</div></div> --- # Why? - When installing packages on travis, each user is given 5,000 free calls per hour - After that, you get a 403 error -- - travis.yml uses `devtools::install_github()` - __devtools__ looks an environment variable called `GITHUB_PAT` - if it doesn't exist, it uses a default (that gets easily overloaded) -- - Solution: Create the PAT! --- # Personal Access Tokens (PAT) * We'll obtain a PAT via the browser - possible to get via __usethis__ --- # DEMO: Personal Access Tokens (PAT) * Create a PAT with no permissions i.e. untick all the permissions boxes - https://github.com/settings/tokens - I typically call mine GITHUB_PAT * Copy the key * We want to store the key in our `.Renviron` file ```r ## Open the file usethis::edit_r_environ() ``` * Add the line ``` GITHUB_PAT=YOUR-PAT ``` * Restart R and run `Sys.getenv("GITHUB_PAT")` --- # TASK: Personal Access Tokens (PAT) * Create a PAT with no permissions i.e. untick all the permissions boxes - https://github.com/settings/tokens - I typically call mine GITHUB_PAT * Copy the key * We want to store the key in our `.Renviron` file ```r ## Open the file usethis::edit_r_environ() ``` * Add the line ``` GITHUB_PAT=YOUR-PAT ``` * Restart R and run `Sys.getenv("GITHUB_PAT")`
10
:
00
--- # DEMO: Now add it to GITHUB Run ```r travis::travis_browse() ``` to get to your travis page * More options -> settings -> Environment variables * NAME: `GITHUB_PAT` * VALUE: `Long string` * Click `Add` * Re-run your travis build * Line ~563 you should see `export GITHUB_PAT=[secure]` --- # TASK: Now add it to GITHUB Run ```r travis::travis_browse() ``` to get to your travis page * More options -> settings -> Environment variables * NAME: `GITHUB_PAT` * VALUE: `Long string` * Click `Add` * Re-run your travis build * Line ~563 you should see `export GITHUB_PAT=[secure]` * Bonus: Try and get travis to print out your secured variable - `Sys.getenv("GITHUB_PAT")`
12
:
00