Skip to content

Instantly share code, notes, and snippets.

@bryanhanson
Last active January 25, 2020 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bryanhanson/5d02c55b8e1178e84b7c119a7c6ca92b to your computer and use it in GitHub Desktop.
Save bryanhanson/5d02c55b8e1178e84b7c119a7c6ca92b to your computer and use it in GitHub Desktop.
Set up Github authorization on your local machine
# R code
# Based on https://stackoverflow.com/a/23810363/633251
# This is called "Web Application Flow"
# see https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/#web-application-flow
# Follow the instructions there to set up a token. Never share your key or secret.
library("httr")
myapp <- oauth_app("FOSS", key = "pqr", secret = "xyz")
github_token <- oauth2.0_token(oauth_endpoints("github"), myapp)
# In the R console you will have the option to save an authorization file
# or do a one time authorization. Then a web page will open with a message
# and you can close it after reading the message.
# The object github_token is now in your workspace can can be called when
# accessing the Github API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment