Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix github codespaces tokens always erroring #58

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/sources/github/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ impl GithubProvider {
pub fn new_authenticated(pat: impl AsRef<str>) -> GithubResult<Self> {
let pat: String = pat.as_ref().trim().to_string();
// https://github.blog/2021-04-05-behind-githubs-new-authentication-token-formats/
if pat.starts_with("ghp_") || pat.starts_with("gho_") {
// github codespaces uses ghu: ^ghu_[a-zA-z1-9]{36}$ (match ghu_N where N is 36 alphanumeric characters)
// https://discord.com/channels/385151591524597761/385151591998816257/1267180689825202256
if pat.starts_with("ghp_") || pat.starts_with("gho_") || pat.starts_with("ghu_") {
Self::new_inner(Some(pat))
} else {
Err(GithubError::UnrecognizedAccessToken)
Expand Down
2 changes: 1 addition & 1 deletion lib/sources/github/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::tool::{ToolId, ToolSpec};

#[derive(Debug, Error)]
pub enum GithubError {
#[error("unrecognized access token format - must begin with `ghp_` or `gho_`.")]
#[error("unrecognized access token format - must begin with `ghp_`, `gho_`, or `ghu_`.")]
UnrecognizedAccessToken,
#[error("no latest release was found for tool '{0}'")]
LatestReleaseNotFound(Box<ToolId>),
Expand Down
Loading