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

Implement abstraction for token authentication #12

Merged
merged 19 commits into from
Nov 30, 2023
Merged

Conversation

kfcampbell
Copy link
Member

@kfcampbell kfcampbell commented Nov 28, 2023

The GitHub provider has been implemented. Creating a client will now look like this:

        token := os.Getenv("GITHUB_TOKEN")
	if token == "" {
		log.Fatalf("GITHUB_TOKEN must be provided")
	}

	tokenProvider := auth.NewTokenProvider(
            auth.WithAuthorizationToken(token))
            /* other options: WithUserAgent, WithAPIVersion, or a user-defined function. 
            if not present, sensible defaults will be used */

	adapter, err := http.NewNetHttpRequestAdapter(tokenProvider)
	if err != nil {
		log.Fatalf("Error creating request adapter: %v", err)
	}

	client := octokit.NewApiClient(adapter)

@kfcampbell kfcampbell marked this pull request as ready for review November 29, 2023 23:36
Copy link
Collaborator

@nickfloyd nickfloyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💥 Looks good.

@kfcampbell kfcampbell merged commit 8971919 into main Nov 30, 2023
3 checks passed
@kfcampbell kfcampbell deleted the authentication branch November 30, 2023 21:00
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

Successfully merging this pull request may close these issues.

2 participants