github

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

ProviderSet is a Wire provider set that includes all the providers from the github package.

Functions

This section is empty.

Types

type Config

type Config struct {
	ClientID     string
	ClientSecret string
}

Config is a struct that holds the configuration for the GitHub service.

func ProvideConfig

func ProvideConfig(cfg *config.Config) *Config

ProvideConfig is a Wire provider function that creates a Config.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service holds GitHub OAuth configuration.

func NewService

func NewService(clientID, clientSecret string) *Service

NewService creates a new GitHub Service instance with the given client ID and client secret.

func ProvideService

func ProvideService(cfg *Config) *Service

ProvideService is a Wire provider function that creates a Service.

func (*Service) ExchangeCodeForToken

func (g *Service) ExchangeCodeForToken(ctx context.Context, code string) (string, error)

ExchangeCodeForToken exchanges the given code from https://github.com/login/oauth/authorize?client_id=&redirect_uri= for an access token.

func (*Service) GetUserInfo

func (g *Service) GetUserInfo(ctx context.Context, token string) (*UserInfo, error)

GetUserInfo returns user info from GitHub using the given access token from Service.ExchangeCodeForToken.

type ServiceInterface

type ServiceInterface interface {
	ExchangeCodeForToken(ctx context.Context, code string) (string, error)
	GetUserInfo(ctx context.Context, token string) (*UserInfo, error)
}

type UserInfo

type UserInfo struct {
	Login             string    `json:"login"`
	ID                int       `json:"id"`
	NodeID            string    `json:"node_id"`
	AvatarURL         string    `json:"avatar_url"`
	GravatarID        string    `json:"gravatar_id"`
	URL               string    `json:"url"`
	HTMLURL           string    `json:"html_url"`
	FollowersURL      string    `json:"followers_url"`
	FollowingURL      string    `json:"following_url"`
	GistsURL          string    `json:"gists_url"`
	StarredURL        string    `json:"starred_url"`
	SubscriptionsURL  string    `json:"subscriptions_url"`
	OrganizationsURL  string    `json:"organizations_url"`
	ReposURL          string    `json:"repos_url"`
	EventsURL         string    `json:"events_url"`
	ReceivedEventsURL string    `json:"received_events_url"`
	Type              string    `json:"type"`
	SiteAdmin         bool      `json:"site_admin"`
	Name              string    `json:"name"`
	Company           string    `json:"company"`
	Blog              string    `json:"blog"`
	Location          string    `json:"location"`
	Email             string    `json:"email"`
	Hireable          bool      `json:"hireable"`
	Bio               string    `json:"bio"`
	TwitterUsername   string    `json:"twitter_username"`
	PublicRepos       int       `json:"public_repos"`
	PublicGists       int       `json:"public_gists"`
	Followers         int       `json:"followers"`
	Following         int       `json:"following"`
	CreatedAt         time.Time `json:"created_at"`
	UpdatedAt         time.Time `json:"updated_at"`
}

UserInfo is a struct to hold GitHub user data.

Jump to

Keyboard shortcuts

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