Skip to content

Instantly share code, notes, and snippets.

@ctrombley
Last active November 8, 2018 05:56
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctrombley/296c2d9eb2738642b953debfc7404b12 to your computer and use it in GitHub Desktop.
Save ctrombley/296c2d9eb2738642b953debfc7404b12 to your computer and use it in GitHub Desktop.
Working Yahoo OAuth2.0 OOB flow
# Requires httr fork available here:
# https://github.com/ctrombley/httr
library(httr)
library(httpuv)
endpoint <- oauth_endpoint("get_request_token", "request_auth", "get_token",
base_url = "https://api.login.yahoo.com/oauth2")
app <- oauth_app("yahoo",
key = "YOUR_CLIENT_ID",
secret = "YOUR_SECRET",
redirect_uri = "oob")
token <- oauth2.0_token(endpoint, app, use_oob = TRUE, as_header = TRUE,
use_basic_auth = TRUE, cache = TRUE)
config <- httr::config(token = token)
teamId <- "YOUR_TEAM_ID"
url <- sprintf("https://fantasysports.yahooapis.com/fantasy/v2/team/%s?response=json", teamId)
res <- GET(url, config)
teamRoster <- content(res)
print(teamRoster)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment