util

package
v0.0.0-...-9a529fd Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2017 License: MIT, MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AuthsFileName string

AuthsFileName is where the authentication tokens are stored. Defaults to $HOME/.ttnctl/auths.json

Functions

func ConnectMQTTClient

func ConnectMQTTClient(ctx log.Interface) mqtt.Client

ConnectMQTTClient connects a new MQTT clients with the specified credentials

func GetAppEUI

func GetAppEUI(ctx log.Interface) types.AppEUI

func GetHandlerManager

func GetHandlerManager(ctx log.Interface) core.AuthHandlerClient

func Logout

func Logout(server string) error

Logout deletes the token for the specified server

func NewRequestWithAuth

func NewRequestWithAuth(server, method, urlStr string, body io.Reader) (*http.Request, error)

NewRequestWithAuth creates a new HTTP request and adds the access token of the authenticated user as bearer token

func ParseHEX

func ParseHEX(input string, length int) ([]byte, error)

ParseHEX parses a hexidecimal string to a byte slice

Types

type App

type App struct {
	EUI        types.AppEUI `json:"eui"` // TODO: Change to []string
	Name       string       `json:"name"`
	Owner      string       `json:"owner"`
	AccessKeys []string     `json:"accessKeys"`
	Valid      bool         `json:"valid"`
}

func GetApplications

func GetApplications(ctx log.Interface) ([]*App, error)

type Auth

type Auth struct {
	AccessToken  string    `json:"access_token"`
	RefreshToken string    `json:"refresh_token"`
	Email        string    `json:"email"`
	Expires      time.Time `json:"expires"`
}

Auth represents an authentication token

func LoadAuth

func LoadAuth(server string) (*Auth, error)

LoadAuth loads the authentication token for the specified server and attempts to refresh the token if it has been expired

func Login

func Login(server, email, password string) (*Auth, error)

Login attemps to login using the specified credentials on the server

func RefreshToken

func RefreshToken(server string) (*Auth, error)

RefreshToken refreshes the current token

Jump to

Keyboard shortcuts

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