Search code examples
rubuntugithubrstudiotoken

rstudio+github everyday problem with github token in RStudio (ubuntu)


I've made a public repo at GitHub connected with RStudio for personal R practices. Got a token, authorized, initiated the repo, committed, pushed, pulled... The very next day GitHub didn't see my token and I had to get another token, passing the whole procedure (3 minutes, actually) for re-establishing the connectivity for remote work. Nothing special, but... Every new day I need to generate a GitHub token for being able to commit changes to GitHub repository from RStudio (in this case). I pass the repository initiation, getting the new token, setting it up... but the other day comes and all the settings seem to be out of validity. Though, the token creation/initiation page somehow contains the period of validity for tokens from 30 to 90 days to no expiration at all.

How can it be worked around or is there a better solution for fixing the issue with connectivity? It didn't matter in the beginning, but when you work on a single project. I use ubuntu, the latest RStudio, and the terminal in it for commiting-pushing activities.

Normally, I check the status of my repo via "git status". If I get denied after the first push attempt, I pass the following also in RStudio:

# check the active project directory
```
usethis::git_remotes()
```

# check the credentials set up
```
gitcreds::gitcreds_get() 
```

# create token if needed
```
usethis::create_github_token()
```

# set the token into the register
```
gitcreds::gitcreds_set() 
```

Normally, after having passed this set of commands, thing go well and I can commit within one session/connection without any problems. But, once I log off - the problem occurs...

The error I get: fatal: could not read Username for 'https://github.com': terminal prompts disabled


Solution

  • Does running this in the terminal (not Rstudio), then generating and using the token work?:

    git config --global credential.helper store
    

    source: https://stackoverflow.com/a/64632086/16502170