github

package
v1.21.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package github is the GitHub API client of the GitHub sign-in method: the profile of the signed-in user and their verified email address.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*oauth2.Config
}

func New

func New(config *Config) *Client

func (*Client) GetPrimaryEmail

func (c *Client) GetPrimaryEmail(ctx context.Context, token string) (string, error)

GetPrimaryEmail fetches the primary verified email from the GitHub emails API, falling back to any verified one.

func (*Client) GetUserInfo

func (c *Client) GetUserInfo(ctx context.Context, token string) (*UserInfo, error)

GetUserInfo fetches the user profile from the GitHub API using the access token. The profile email carries no verification metadata, so the email returned is the primary verified one from the emails API, or empty. The requests are bound to ctx, which carries the caller's deadline.

type Config

type Config struct {
	ClientID     string
	ClientSecret string
	RedirectURL  string
}

type EmailInfo

type EmailInfo struct {
	Email    string `json:"email"`
	Primary  bool   `json:"primary"`
	Verified bool   `json:"verified"`
}

EmailInfo represents a GitHub email address.

type UserInfo

type UserInfo struct {
	OpenID  int64  `json:"id"`
	Login   string `json:"login"`
	Name    string `json:"name"`
	Email   string `json:"email"`
	Avatar  string `json:"avatar_url"`
	HTMLURL string `json:"html_url"`
}

UserInfo represents the GitHub user information.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL