package
0.0.0-20181213094507-0031c6d985d6
Repository: https://github.com/facchinm/arduino-cli.git
Documentation: pkg.go.dev

# README

= Authorization (auth) package Alessandro Sanino [email protected]

This package allows to connect via OAuth2.0 to the arduino.cc system (Hydra)

See test package for an example of usage.

==== Basic usage [source, go]

// Just create a new auth object. authObj := auth.New() token, err := auth.Token(testUser, testPass) if err != nil { // Handle error }

// Then use the generated token in your requests, for example: // Obtain info of my user. req, err := http.NewRequest("GET", "https://auth.arduino.cc/v1/users/byID/me", nil) if err != nil { // Handle error } req.Header.Add("Authorization", "Bearer "+token.Access) client := http.Client{} resp, err := client.Do(req) if err != nil { // Handle error }

// Before your token expires, you can do a refresh to have a new one for the // same session: newToken, err := auth.Refresh(token.Access) if err != nil { // Handle error }

# Functions

New returns an auth configuration with sane defaults.

# Structs

Config contains the variables you may want to change.
Token is the response of the two authentication functions.