Version: v7.1.0 Latest Latest

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

Go to latest
Published: May 19, 2021 License: Apache-2.0 Imports: 3 Imported by: 0



Package session allows direct access to the SDK session management API. Use it to obtain a Single Sign On (SSO) token from Access Management.

This example shows how to use a username and password to authenticate and obtain an SSO token:

// Connect directly to AM
amURL, _ := url.Parse("")

// Create a session by authenticating with a username and password
session, _ := builder.Session().
        callback.NameHandler{Name: "my-device"},
        callback.PasswordHandler{Password: "password"}).

// The SSO token can be used to authorize REST requests directly with AM
ssoToken := session.Token()



This section is empty.


This section is empty.


This section is empty.


type Builder

type Builder interface {

	// ConnectTo the server at the given URL.
	// Supports http(s) for connecting to AM and coap(s) for connecting to the IoT Gateway.
	ConnectTo(url *url.URL) Builder

	// InRealm specifies the path to the AM realm in which to authenticate.
	// The realm is not required if connecting to the IoT Gateway. If provided it will be ignored.
	InRealm(realm string) Builder

	// WithTree sets the name of the AM authentication tree that will be used for authentication.
	// The tree is not required if connecting to the IoT Gateway. If provided it will be ignored.
	WithTree(tree string) Builder

	// AuthenticateWith the supplied callback handlers when creating the session. The provided handlers must
	// match those configured in the AM authentication tree.
	AuthenticateWith(handlers ...callback.Handler) Builder

	// TimeoutRequestAfter sets the timeout on the communications between the Thing and AM or the IoT Gateway.
	TimeoutRequestAfter(d time.Duration) Builder

	// Create a Session instance and make an authentication request to AM. The callback handlers provided
	// will be used to satisfy the callbacks received from the AM authentication process.
	Create() (Session, error)

type Session

type Session interface {

	// Token returns the session token.
	Token() string

	// Valid returns true if the session is valid.
	Valid() (bool, error)

	// Logout the session.
	Logout() error

Session represents an authenticated session with AM.

Source Files

Jump to

Keyboard shortcuts

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