Skip to content

use_pkgdown_github_pages fails for GHE - .token not supplied #2184

@daniepi

Description

@daniepi

Hi,
Trying to setup pkgdown for package hosted on GitHub (GHE) to no avail. PAT is set and recognized by usethis.
However following error is thrown

usethis::use_pkgdown_github_pages()
Error in `github_remotes()`:Unable to get GitHub info for these remotes: "origin".Are we offline? Is GitHub down? Has the repo been deleted?
ℹ Otherwise, you probably need to configure a personal access token (PAT) for "xxx.ghe.com".See usethis::gh_token_help() for advice.

Digging through the code it took me through usethis:::target_repo --> usethis:::github_remote_config --> usethis:::github_remotes.
I can see gh::gh being called from within usethis:::github_remotes with owner, repo and .api_url supplied. However, .token is not being supplied and calling

grl <- usethis:::github_remotes(github_get = TRUE)
gh::gh(endpoint = "GET /repos/{owner}/{repo}", owner = grl$repo_owner, repo = grl$repo_name, .api_url = grl$api_url)
GitHub API error (401): Must authenticate to access this API.

When I call this function as follows

grl <- usethis:::github_remotes(github_get = TRUE)
creds <- gitcreds::gitcreds_get(url = "xxx.ghe.com")
gh::gh(endpoint = "GET /repos/{owner}/{repo}", owner = grl$repo_owner, repo = grl$repo_name, .api_url = grl$api_url, .token = creds$password)

I get response. Using standard github.com (personal account) works fine even without supplying .token to the above call. Supplying wrong token results in 401 while supplying correct token returns.
Am I missing something here?

Thanks a lot for help. :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions