octokit / go-sdk

A generated Go SDK from GitHub's OpenAPI specification. Built on Kiota.
MIT License
64 stars 7 forks source link

Implement abstraction for token authentication #12

Closed kfcampbell closed 8 months ago

kfcampbell commented 9 months ago

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)