GitHub PAT works in RStudio with `usethis` package as admin but not as non-admin user on Windows

Problem

I am trying to set up GitHub authentication in RStudio on Windows using a Personal Access Token (PAT). When I run RStudio as an administrator, I can successfully set and use the PAT with gitcreds::gitcreds_set() and perform GitHub operations like cloning repositories. However, when I run RStudio as a non-admin user, the credentials do not persist, and GitHub authentication fails.

What I Tried

1. Setting the PAT using gitcreds::gitcreds_set():

  • As an admin user, I run gitcreds::gitcreds_set(). I enter the PAT, and it works. I can verify it with gitcreds::gitcreds_get() and use it for GitHub operations like usethis::create_from_github()

  • As a non-admin user, I run the same commands, but the credentials do not persist. Even when creating a new PAT, it does now rok. Here’s an example:

> usethis::create_github_token()
☐ Call gitcreds::gitcreds_set() to register this token in the local Git credential store.
ℹ It is also a great idea to store this token in any password-management software that you use.
✔ Opening URL
  <https://github.com/settings/tokens/new?scopes=repo,user,gist,workflow&description=DESCRIBE THE
  TOKEN'S USE CASE>.
> usethis::create_github_token()
☐ Call gitcreds::gitcreds_set() to register this token in the local Git credential store.
ℹ It is also a great idea to store this token in any password-management software that you use.
✔ Opening URL
  <https://github.com/settings/tokens/new?scopes=repo,user,gist,workflow&description=DESCRIBE THE
  TOKEN'S USE CASE>.
> gitcreds::gitcreds_set()


? Enter password or token: ghp_XXXXXXXXXXnot_sharingXXXXXXXXXXXXXXXXX
-> Adding new credentials...
-> Removing credentials from cache...
-> Done.
> usethis::gh_token_help()
• GitHub host: "https://github.com"
• Personal access token for "https://github.com": <unset>
☐ To create a personal access token, call usethis::create_github_token().
☐ To store a token for current and future use, call gitcreds::gitcreds_set().
ℹ Read more in the Managing Git(Hub) Credentials article.

2. Setting the token explicitly in the R session:

  • Using `Sys.setenv(GITHUB_PAT = “ghp_XXXXXXXXXXnot_sharingXXXXXXXXXXXXXXXXX”) works temporarily, but this is not a permanent solution.

Environment

  • OS: Windows 10 Pro, version 22H2
  • RStudio Version: 2024.9.1.394
  • R Version: 4.3.0
  • Git Version: 2.45.2.windows.1
  • GitHub PAT: Classic token with repo, workflow, and user scopes.

Program paths in Windows

> normalizePath(R.home())  
[1] "C:\Program Files\R\R-4.3.0"
> normalizePath(Sys.which("git"))  
[1] "C:\Program Files\Git\cmd\git.exe"

What I Suspect

I believe this is a permissions issue with the credential storage mechanism. When running RStudio as an admin, the credentials are stored in a location that is inaccessible to the non-admin user. However, I am unsure how to configure the system so that the non-admin user can securely store and access the credentials.

What I Need Help With

  1. How can I configure RStudio or Windows so that the non-admin user can securely store and access the GitHub PAT?
  2. Is there a way to adjust permissions for the credential storage mechanism (e.g., Windows Credential Manager or Git configuration) to resolve this issue?

What I Want to Avoid

  • Storing the PAT in .Renviron or using Sys.setenv() as these are less secure.
  • Running RStudio as an administrator every time.

Any Suggestions?

I would appreciate any guidance on how to resolve this issue or insights into how RStudio and gitcreds handle credential storage on Windows.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật