1package api 2 3// AccessToken is an OAuth access token. 4type AccessToken struct { 5 // The token value, typically a 40-character random string. 6 Token string 7 // The refresh token value, associated with the access token. 8 RefreshToken string 9 // The token type, e.g. "bearer". 10 Type string 11 // Space-separated list of OAuth scopes that this token grants. 12 Scope string 13} 14 15// AccessToken extracts the access token information from a server response. 16func (f FormResponse) AccessToken() (*AccessToken, error) { 17 if accessToken := f.Get("access_token"); accessToken != "" { 18 return &AccessToken{ 19 Token: accessToken, 20 RefreshToken: f.Get("refresh_token"), 21 Type: f.Get("token_type"), 22 Scope: f.Get("scope"), 23 }, nil 24 } 25 26 return nil, f.Err() 27} 28