Token Expiration on URLs to Private Repos

I have a private repo.

On a web app I’m developing I want to pull in raw code from a particular file in that private repo.

When accessing that raw file via a browser on Github.com, Github appends a token to the URL. That file can then be accessed over https from any computer using that URL with the token.

Question: does the authentication token expire? And if so, when? This is not a token I created, it was automatically appended to the URL when I was browsing my private Github repo.

5 Likes

Hi @shaigluskin,

Thank you for being here! The token will expire in 7 days.

1 Like

Is there a way that I can get a permanent token for this use-case?

Generally speaking, I don’t think so, but why don’t you go ahead and send a ticket support request at https://github.com/contact with the info, so we can look into that further. I’m not sure how or if the team handles exceptions, but is worth an ask.

Even tried with a permanent token from https://github.com/settings/tokens , but that won’t even allow loading the url. Why the hell is that not supported? :frowning:

You can use a personal access token, which doesn’t expire unless unused for an entire year.

And then fetch the file with something like:

curl -H 'Authorization: token <personal_token>' <raw_url>

The <raw_url> should  have the autogenerated “?token=AAABBBCCC…” part of the url removed before making the request with your personal token.