iam

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2021 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const IAMTokenURL = "https://iam.cloud.ibm.com/oidc/token"

IAMTokenURL is the global endpoint URL for the IAM token service

Variables

View Source
var (
	// RetryWaitMax is the maximum time to wait between HTTP retries
	RetryWaitMax = 30 * time.Second

	// RetryMax is the max number of attempts to retry for failed HTTP requests
	RetryMax = 4
)

Functions

This section is empty.

Types

type Error

type Error struct {
	ErrorCode    string             `json:"errorCode"`
	ErrorMessage string             `json:"errorMessage"`
	Context      *iamRequestContext `json:"context"`
	HTTPResponse *http.Response
}

Error is a type to hold error information that the IAM services sends back when a request cannot be completed. ErrorCode, ErrorMessage, and Context.RequestID are probably the most useful fields. IAM will most likely ask you for the RequestID if you ask for support.

Also of note is that the http.Response object is included in HTTPResponse for error handling at the higher application levels.

func (Error) Error

func (ie Error) Error() string

type IAMTokenSource

type IAMTokenSource struct {
	TokenURL string
	APIKey   string
	// contains filtered or unexported fields
}

IAMTokenSource is used to retrieve access tokens from the IAM token service. Most will probably want to use CredentialFromAPIKey to build an IAMTokenSource type, but it can also be created directly if one wishes to override the default IAM endpoint by setting TokenURL

func CredentialFromAPIKey

func CredentialFromAPIKey(apiKey string) *IAMTokenSource

CredentialFromAPIKey returns an IAMTokenSource that requests access tokens from the default token endpoint using an IAM API Key as the authentication mechanism

func (*IAMTokenSource) Token

func (ts *IAMTokenSource) Token() (*Token, error)

Token requests an access token from IAM using the IAMTokenSource config.

type Token

type Token struct {
	AccessToken  string
	RefreshToken string
	TokenType    string
	Expiry       time.Time
}

Token represents an IAM credential used to authorize requests to another service.

func (*Token) Valid

func (t *Token) Valid() bool

type TokenSource

type TokenSource interface {
	Token() (*Token, error)
}

Jump to

Keyboard shortcuts

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