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

403 from client init #112

Open
adrien-barret opened this issue Jan 18, 2024 · 0 comments
Open

403 from client init #112

adrien-barret opened this issue Jan 18, 2024 · 0 comments

Comments

@adrien-barret
Copy link

adrien-barret commented Jan 18, 2024

Hi,

I'm trying to use ghinstallation but I m facing a issue with token auth.

2024/01/18 21:17:55 Get "https://api.github.com/orgs/my-organization/teams": could not refresh installation id 47247922's token: received non 2xx response status "403 Forbidden" when fetching https://github.com/app/installations/47247922/access_tokens

code:

func main() {
	tr := http.DefaultTransport
	var AppID int64 = 120309
	var InstallationID int64 = 47247922
	// Wrap the shared transport for use with the app ID 1 authenticating with installation ID 99.
	itr, err := ghinstallation.NewKeyFromFile(tr, AppID, InstallationID, "my-private-key.private-key.pem")
	if err != nil {
		log.Fatal(err)
	}
	itr.BaseURL = GitHubEnterpriseURL

	ctx := context.Background()
	opt := &github.ListOptions{}

	client := github.NewClient(&http.Client{Transport: itr})

	ListTeams, _, err := client.Teams.ListTeams(ctx, "my-organization", opt)
	if err != nil {
		log.Fatal(err)
	}
	log.Println(ListTeams)
}

not sure to understand correctly but the call stop at the authentication. the github account is a paid organization in github saas not self hosted. The permissions look like: Read access to actions, members, metadata, organization administration, and pull requests

What I don't understand is that path https://github.com/app/installations/47247922/access_tokens it seems to miss something. If I look my application the url is https://github.com/organizations/my-organization/settings/installations/47247922

I would presume the url needed would be https://github.com/organizations/my-organization/settings/installations/47247922/access_tokens or does I miss something? @bradleyfalzon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant