ghinstallation icon indicating copy to clipboard operation
ghinstallation copied to clipboard

403 from client init

Open adrien-barret opened this issue 1 year ago • 0 comments

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

adrien-barret avatar Jan 18 '24 22:01 adrien-barret