google

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2017 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GoogleAPIUserinfoURL   = "https://www.googleapis.com/oauth2/v1/userinfo?alt=json"
	GoogleAPIPlusPeopleURL = "https://www.googleapis.com/plus/v1/people/me"
	GoogleAPIEmailURL      = "https://www.googleapis.com/userinfo/email"

	UserinfoEmailScope   = "https://www.googleapis.com/auth/userinfo#email"
	UserinfoProfileScope = "https://www.googleapis.com/auth/userinfo.profile"

	SpreadsheetsReadonly     = "https://www.googleapis.com/auth/spreadsheets.readonly"
	SpreadsheetsReadonlyDesc = "Allows read-only access to the user's sheets and their properties."
	Spreadsheets             = "https://www.googleapis.com/auth/spreadsheets"
	SpreadsheetsDesc         = "Allows read/write access to the user's sheets and their properties."

	DriveReadonly     = "https://www.googleapis.com/auth/drive.readonly"
	DriveReadonlyDesc = "Allows read-only access to the user's file metadata and file content."
	DriveFile         = "https://www.googleapis.com/auth/drive.file"
	DriveFileDesc     = "Per-file access to files created or opened by the app."
	Drive             = "https://www.googleapis.com/auth/drive"
	DriveDesc         = "Full, permissive scope to access all of a user's files. Request this scope only when it is strictly necessary."
)

Variables

View Source
var (
	ClientSecretEnv = "GOOGLE_APP_CLIENT_SECRET"
)

Functions

func ClientFromFile

func ClientFromFile(ctx context.Context, filepath string, scopes []string, tok *oauth2.Token) (*http.Client, error)

func ConfigFromEnv

func ConfigFromEnv(envVar string, scopes []string) (*oauth2.Config, error)

func ConfigFromFile

func ConfigFromFile(file string, scopes []string) (*oauth2.Config, error)

Types

type ClientUtil

type ClientUtil struct {
	Client *http.Client
	User   GoogleUserinfo `json:"user,omitempty"`
}

ClientUtil is a client library to retrieve the /userinfo endpoint which is not included in the Google API Go Client. For other endpoints, please consider using The Google API Go Client: https://github.com/google/google-api-go-client

func NewClientUtil

func NewClientUtil(client *http.Client) ClientUtil

func (*ClientUtil) GetPlusPerson

func (apiutil *ClientUtil) GetPlusPerson() (GooglePlusPerson, error)

GetPlusPerson retrieves the userinfo from the https://www.googleapis.com/oauth2/v1/userinfo?alt=json endpoint.

func (*ClientUtil) GetSCIMUser

func (apiutil *ClientUtil) GetSCIMUser() (scimutil.User, error)

func (*ClientUtil) GetUserinfo

func (apiutil *ClientUtil) GetUserinfo() (GoogleUserinfo, error)

GetUserinfo retrieves the userinfo from the https://www.googleapis.com/oauth2/v1/userinfo?alt=json endpoint.

func (*ClientUtil) GetUserinfoEmail

func (apiutil *ClientUtil) GetUserinfoEmail() (GoogleUserinfoEmail, error)

GetUserinfoEmail retrieves the user's email from the https://www.googleapis.com/userinfo/email endpoint.

func (*ClientUtil) SetClient

func (apiutil *ClientUtil) SetClient(client *http.Client)

type GooglePlusPerson

type GooglePlusPerson struct {
	Kind        string                `json:"kind,omitempty"`
	Etag        string                `json:"etag,omitempty"`
	Gender      string                `json:"gender,omitempty"`
	ObjectType  string                `json:"objectType,omitempty"`
	ID          string                `json:"id,omitempty"`
	DisplayName string                `json:"displayName,omitempty"`
	Name        GooglePlusPersonName  `json:"name,omitempty"`
	URL         string                `json:"url,omitempty"`
	Image       GooglePlusPersonImage `json:"image,omitempty"`
	IsPlusUser  bool                  `json:"isPlusUser,omitempty"`
	Language    string                `json:"language,omitempty"`
	Verified    bool                  `json:"verified,omitempty"`
}

type GooglePlusPersonImage

type GooglePlusPersonImage struct {
	URL       string `json:"url,omitempty"`
	IsDefault bool   `json:"isDefault,omitempty"`
}

type GooglePlusPersonName

type GooglePlusPersonName struct {
	FamilyName string `json:"familyName,omitempty"`
	GivenName  string `json:"givenName,omitempty"`
}

type GoogleUserinfo

type GoogleUserinfo struct {
	FamilyName string `json:"family_name,omitempty"`
	Gender     string `json:"gender,omitempty"`
	GivenName  string `json:"given_name,omitempty"`
	ID         string `json:"id,omitempty"`
	Link       string `json:"link,omitempty"`
	Locale     string `json:"locale,omitempty"`
	Name       string `json:"name,omitempty"`
	PictureURL string `json:"picture,omitempty"`
}

type GoogleUserinfoEmail

type GoogleUserinfoEmail struct {
	Email      string `json:"email,omitempty"`
	IsVerified bool   `json:"isVerified,omitempty"`
}

func ParseGoogleUserinfoEmail

func ParseGoogleUserinfoEmail(query string) (GoogleUserinfoEmail, error)

Jump to

Keyboard shortcuts

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