I use the R
package httr
to authenticate myself at an oauth endpoint (strava) using oauth_endpoint()
, oauth_app()
and oauth2.0_token()
(Step 1).
# Step 1: Genrate oauth token
strava_endpoint <- oauth_endpoint(
request = NULL,
authorize = "authorize",
access = "token",
base_url = "https://www.strava.com/api/v3/oauth/"
)
myapp <- oauth_app(
"strava",
key = 0000000, # <- my key
secret = "mysecret" # <- my secret
)
mytok <- oauth2.0_token(
endpoint = strava_endpoint,
app = myapp,
scope = c("activity:read_all"),
cache = TRUE
)
This last function requires me to authenticate via browser and permit the requested scope, which is then cached as a token .httr-oauth
. After doing this once, I can use this token file with readRDS()
to use GET()
via the strava API (Step 2)
# Step 2: Use the file ".httr-oauth" got use the API (GET)
mytok <- readRDS(".httr-oauth")[[1]]
GET("https://www.strava.com/api/v3/athlete", config(token = mytok))
Response [https://www.strava.com/api/v3/athlete]
Date: 2022-03-09 07:53
Status: 200
Content-Type: application/json; charset=utf-8
Size: 650 B
This works fine locally. However, I would like to pass this token to a github action to GET()
on my behalf. In other words, I want to do Step 1 locally and use the generated token (file .httr-oauth
) in a Github Action (Step 2)
But, since this token is a secret and should be added to .gitignore
, I don't know how to authenticate the github action.
I thought I could add .httr-oauth
as a github secret, but it seems to be an encrypted file.
Is there a different way to authorize a github action to GET()
my data via an API (e.g. strava)?