github.com/crosbymichael/octokat@v0.0.0-20160826194511-076a32289ed5/authorizations.go (about) 1 package octokat 2 3 import ( 4 "time" 5 ) 6 7 type Authorization struct { 8 ID int `json:"id,omitempty"` 9 URL string `json:"url,omitempty"` 10 App App `json:"app,omitempty"` 11 Token string `json:"token,omitempty"` 12 Note string `json:"note,omitempty"` 13 NoteURL string `json:"note_url,omitempty"` 14 Scopes []string `json:"scopes,omitempty"` 15 CreatedAt time.Time `json:"created_at,omitempty"` 16 UpdatedAt time.Time `json:"updated_at,omitempty"` 17 } 18 19 type App struct { 20 ClientID string `json:"client_id,omitempty"` 21 URL string `json:"url,omitempty"` 22 Name string `json:"name,omitempty"` 23 } 24 25 // List the authenticated user's authorizations 26 // 27 // API for users to manage their own tokens. 28 // You can only access your own tokens, and only through 29 // Basic Authentication. 30 // 31 // See http://developer.github.com/v3/oauth/#list-your-authorizations 32 func (c *Client) Authorizations(options *Options) (auths []Authorization, err error) { 33 err = c.jsonGet("authorizations", options, &auths) 34 return 35 } 36 37 type AuthorizationParams struct { 38 Scopes []string `json:"scopes,omitempty"` 39 Note string `json:"note,omitempty"` 40 NoteURL string `json:"note_url,omitempty"` 41 ClientID string `json:"client_id,omitempty"` 42 ClientSecret string `json:"client_secret,omitempty"` 43 } 44 45 // Create an authorization for the authenticated user. 46 // 47 // You can create your own tokens, and only through 48 // Basic Authentication. 49 // 50 // See http://developer.github.com/v3/oauth/#scopes Available scopes 51 // See http://developer.github.com/v3/oauth/#create-a-new-authorization 52 func (c *Client) CreateAuthorization(options *Options) (auth *Authorization, err error) { 53 err = c.jsonPost("authorizations", options, &auth) 54 return 55 }