Documentation
¶
Overview ¶
Package auth uses the `oauth2 authorization_code` flow to authenticate with Arduino
If you have the username and password of a user, you can just instantiate a client with sane defaults:
client := auth.New()
and then call the Token method to obtain a Token object with an AccessToken and a RefreshToken
token, err := client.Token(username, password)
If instead you already have a token but want to refresh it, just call
token, err := client.refresh(refreshToken)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckDeviceAuth ¶
Types ¶
type Config ¶
type Config struct {
// CodeURL is the endpoint to redirect to obtain a code
CodeURL string
// TokenURL is the endpoint where you can request an access code
TokenURL string
// ClientID is the client id you are using
ClientID string
// RedirectURI is the redirectURI where the oauth process will redirect. It's only required since the oauth system checks for it, but we intercept the redirect before hitting it
RedirectURI string
// Scopes is a space-separated list of scopes to require
Scopes string
}
Config contains the variables you may want to change
type DeviceCode ¶
type DeviceCode struct {
DeviceCode string `json:"device_code"`
UserCode string `json:"user_code"`
VerificationURI string `json:"verification_uri"`
ExpiresIn int `json:"expires_in"`
Interval int `json:"interval"`
VerificationURIComplete string `json:"verification_uri_complete"`
}
func StartDeviceAuth ¶
func StartDeviceAuth(authURL, clientID string) (data DeviceCode, err error)
StartDeviceAuth request with POST auth using clientID
type HTTPClient ¶
type HTTPClient interface {
Do(req *http.Request) (*http.Response, error)
Get(url string) (resp *http.Response, err error)
}
HTTPClient interface
type Token ¶
type Token struct {
// Access is the token to use to authenticate requests
Access string `json:"access_token"`
// Refresh is the token to use to request another access token. It's only returned if one of the scopes is "offline"
Refresh string `json:"refresh_token"`
// TTL is the number of seconds that the tokens will last
TTL int `json:"expires_in"`
// Scopes is a space-separated list of scopes associated to the access token
Scopes string `json:"scope"`
// Type is the type of token
Type string `json:"token_type"`
}
Token is the response of the two authentication functions
Click to show internal directories.
Click to hide internal directories.