ims

package
v0.4.1-0...-8504ca3 Latest Latest
Warning

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

Go to latest
Published: May 18, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorizeURLConfig

type AuthorizeURLConfig struct {
	ClientID    string
	GrantType   GrantType
	Scope       []string
	RedirectURI string
	State       string
}

AuthorizeURLConfig is the configuration for building an uthorization URL.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the client for the IMS API.

func NewClient

func NewClient(cfg *ClientConfig) (*Client, error)

NewClient creates a new Client for the given configuration.

func (*Client) AuthorizeURL

func (c *Client) AuthorizeURL(cfg *AuthorizeURLConfig) (string, error)

AuthorizeURL builds an authorization URL according to the provided configuration.

func (*Client) ExchangeJWT

func (c *Client) ExchangeJWT(r *ExchangeJWTRequest) (*ExchangeJWTResponse, error)

ExchangeJWT exchanges a JWT token for an access token.

func (*Client) RefreshToken

func (c *Client) RefreshToken(r *RefreshTokenRequest) (*RefreshTokenResponse, error)

RefreshToken refreshes an access token.

func (*Client) Token

func (c *Client) Token(r *TokenRequest) (*TokenResponse, error)

Token requests an access token.

type ClientConfig

type ClientConfig struct {
	// URL is the endpoint for the IMS API.
	URL string
	// Client is the HTTP client to use when performing requests. If not
	// provided, the default HTTP client is used.
	Client *http.Client
}

ClientConfig is the configuration for a Client.

type Error

type Error struct {
	// StatusCode is the status code of the response returning the error.
	StatusCode int
	// ErrorCode is an error code associated with the error response.
	ErrorCode string
	// ErrorMessage is a human-readable description of the error.
	ErrorMessage string
}

Error is an error containing information returned by the IMS API.

func IsError

func IsError(err error) (*Error, bool)

IsError checks if the given error is an IMS error and, if it is, returns an instance of Error.

func (*Error) Error

func (e *Error) Error() string

type ExchangeJWTRequest

type ExchangeJWTRequest struct {
	// The private key for signing the JWT token. This field is required.
	PrivateKey []byte
	// The expiration time for the access token. This field is required.
	Expiration time.Time
	// The issuer of the JWT token. It represents the identity of the
	// organization issuing the token. This field is required.
	Issuer string
	// The subject of the JWT token. It represents the identity of the technical
	// account.
	Subject string
	// The client ID.
	ClientID string
	// The client secret.
	ClientSecret string
	// The additional meta-scopes to add to the JWT token.
	MetaScope []MetaScope
}

ExchangeJWTRequest contains the data for exchanging a JWT token with an access token.

type ExchangeJWTResponse

type ExchangeJWTResponse struct {
	AccessToken string
	ExpiresIn   time.Duration
}

ExchangeJWTResponse contains the response of a successful exchange of a JWT token.

type GrantType

type GrantType int

GrantType is the grant type specified when building an authorization URL.

const (
	// GrantTypeDefault is the default grant type as specified by IMS.
	GrantTypeDefault GrantType = iota
	// GrantTypeCode is the authorization code grant type.
	GrantTypeCode
	// GrantTypeImplicit is the implicit grant type.
	GrantTypeImplicit
	// GrantTypeDevice is the device token grant type.
	GrantTypeDevice
)

type MetaScope

type MetaScope int

MetaScope is a meta-scope that can be optionally added to a JWT token.

const (
	// MetaScopeCloudManager is the meta-scope for Cloud Manager
	MetaScopeCloudManager MetaScope = iota
	// MetaScopeAdobeIO is the meta-scope for Adobe IO
	MetaScopeAdobeIO
	// MetaScopeAnalyticsBulkIngest is the meta-scope for Analytics Bulk Ingest
	MetaScopeAnalyticsBulkIngest
)

type RefreshTokenRequest

type RefreshTokenRequest struct {
	// RefreshToken is the refresh token obtained during the first request for
	// an access token. This field is required.
	RefreshToken string
	// ClientID is the client ID. This field is required.
	ClientID string
	// ClientSecret is the client secret. This field is required.
	ClientSecret string
	// Scope is the scope list in the refresh token. This field is optional. If
	// provided, it must be a subset of the scopes in the request token.
	Scope []string
}

RefreshTokenRequest is the request for refreshing an access token.

type RefreshTokenResponse

type RefreshTokenResponse struct {
	// AccessToken is the new access token.
	AccessToken string
	// RefreshToken is a new refresh token.
	RefreshToken string
	// ExpiresIn is the expiration time for the access token.
	ExpiresIn time.Duration
}

RefreshTokenResponse is the response of an access token refresh.

type TokenRequest

type TokenRequest struct {
	// Code is the authorization code obtained via the authorization workflow.
	// This field is required.
	Code string
	// ClientID is the client ID. This field is required.
	ClientID string
	// ClientSecret is the client secret. This field is required.
	ClientSecret string
	// Scope is the scope of list for the access token. This field is optional.
	// If not provided, the scopes will be bound to the ones requested during
	// the authorization workflow.
	Scope []string
}

TokenRequest is the request for obtaining an access token.

type TokenResponse

type TokenResponse struct {
	// AccessToken is the access token.
	AccessToken string
	// RefreshToken is the refresh token.
	RefreshToken string
	// ExpiresIn is the expiration time of the access token.
	ExpiresIn time.Duration
	// User id received from IMS token
	UserID string
}

TokenResponse is the response returned after an access token request.

Jump to

Keyboard shortcuts

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