FromResponse (oauth/token.go)

bitbucket-cli · pkg/oauth/token.go · go · MIT
auth

Module exposing: FromResponse, IsExpired, Marshal, Unmarshal, IsTokenBlob, Token

// Source: https://github.com/avivsinai/bitbucket-cli | License: MIT | Copyright 2025 Aviv Sinai
// Provided via justclaw.it.com; keep this notice with the code.
package oauth

import (
	"encoding/json"
	"errors"
	"strings"
	"time"
)

// Token holds an OAuth 2.0 access/refresh token pair with expiry.
type Token struct {
	AccessToken  string    `json:"access_token"`
	RefreshToken string    `json:"refresh_token"`
	ExpiresAt    time.Time `json:"expires_at"`
	// ClientID is the consumer that issued the token, the only one that can
	// refresh it. Empty for tokens stored before bkt recorded it.
	ClientID string `json:"client_id,omitempty"`
}

// tokenRefreshGrace is subtracted from ExpiresAt when checking expiry so tokens
// are refreshed slightly before the server considers them stale.
const t

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key