⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@madhav-db
Copy link
Contributor

Two comprehensive examples demonstrating token provider usage:

  1. token_federation: Simple external token provider with federation
  2. browser_oauth_federation: Full browser OAuth flow with automatic token exchange

Both examples show real-world integration patterns for custom authentication.

Two comprehensive examples demonstrating token provider usage:

1. token_federation: Simple external token provider with federation
2. browser_oauth_federation: Full browser OAuth flow with automatic token exchange

Both examples show real-world integration patterns for custom authentication.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
case 3:
s += "="
}
return io.ReadAll(strings.NewReader(s))
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this intentionally left as such? you are actually not decoding anything


// Helper: Test database connection with queries
func testConnection(db *sql.DB) error {
ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
Copy link
Collaborator

Choose a reason for hiding this comment

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

shall we suggest lower timeout value in our examples? Or 120s was intentional?

Copilot AI review requested due to automatic review settings January 28, 2026 10:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds two comprehensive example programs demonstrating token provider usage for authentication in the Databricks Go SQL driver. The examples showcase both simple token federation with external providers and a complete browser-based OAuth flow with automatic token exchange.

Changes:

  • Added token_federation example showing three authentication patterns: static tokens, external token functions, and custom TokenProvider implementations
  • Added browser_oauth_federation example demonstrating User-to-Machine (U2M) OAuth authentication with interactive browser login

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
examples/token_federation/main.go Implements three token authentication patterns with a custom ExpiringTokenProvider demonstrating token lifecycle management
examples/browser_oauth_federation/main.go Demonstrates U2M OAuth flow with browser-based authentication and connection validation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +165 to +166
func (p *ExpiringTokenProvider) GetToken(ctx context.Context) (*tokenprovider.Token, error) {
p.expiresAt = time.Now().Add(p.lifetime)
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

The ExpiringTokenProvider modifies shared state (p.expiresAt) without synchronization. If GetToken is called concurrently from multiple goroutines, this could result in race conditions. Consider adding a mutex to protect access to expiresAt.

Copilot uses AI. Check for mistakes.
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.

3 participants