Skip to content

Commit

Permalink
Use gargle's new secret management (#428)
Browse files Browse the repository at this point in the history
* Use gargle's new secret management

* Switch to new env var

* Bump GHA now that the new secret is in place

* Branch has been merged

* Use new env var
  • Loading branch information
jennybc committed Jun 2, 2023
1 parent 4ddfde6 commit 751464c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
contains(github.event.head_commit.message, '[pkgdown]')
env:
GOOGLEDRIVE_PASSWORD: ${{ secrets.GOOGLEDRIVE_PASSWORD }}
GOOGLEDRIVE_KEY: ${{ secrets.GOOGLEDRIVE_KEY }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/with-auth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ jobs:

- uses: r-lib/actions/check-r-package@v2
env:
GOOGLEDRIVE_PASSWORD: ${{ secrets.GOOGLEDRIVE_PASSWORD }}
GOOGLEDRIVE_KEY: ${{ secrets.GOOGLEDRIVE_KEY }}
11 changes: 8 additions & 3 deletions R/drive_auth.R
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ drive_oauth_client <- function() {
drive_auth_internal <- function(account = c("docs", "testing"),
scopes = NULL) {
account <- match.arg(account)
can_decrypt <- gargle:::secret_can_decrypt("googledrive")
can_decrypt <- gargle::secret_has_key("GOOGLEDRIVE_KEY")
online <- !is.null(curl::nslookup("drive.googleapis.com", error = FALSE))
if (!can_decrypt || !online) {
drive_abort(
Expand All @@ -246,8 +246,13 @@ drive_auth_internal <- function(account = c("docs", "testing"),
# TODO: revisit when I do PKG_scopes()
# https://github.com/r-lib/gargle/issues/103
scopes <- scopes %||% "https://www.googleapis.com/auth/drive"
json <- gargle:::secret_read("googledrive", filename)
drive_auth(scopes = scopes, path = rawToChar(json))
drive_auth(
scopes = scopes,
path = gargle::secret_decrypt_json(
system.file("secret", filename, package = "googledrive"),
"GOOGLEDRIVE_KEY"
)
)
print(drive_user())
invisible(TRUE)
}
Expand Down
Binary file modified inst/secret/googledrive-docs.json
Binary file not shown.
Binary file modified inst/secret/googledrive-testing.json
Binary file not shown.

0 comments on commit 751464c

Please sign in to comment.