xsuaa

package
v1.154.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 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 AuthToken

type AuthToken struct {
	TokenType   string        `json:"token_type"`
	AccessToken string        `json:"access_token"`
	ExpiresIn   time.Duration `json:"expires_in"`
	ExpiresAt   time.Time
}

AuthToken provides a structure for the XSUAA auth token to be marshalled into

type XSUAA

type XSUAA struct {
	OAuthURL        string
	ClientID        string
	ClientSecret    string
	CachedAuthToken AuthToken
}

XSUAA contains the fields to authenticate to a xsuaa service instance on BTP to retrieve a access token It also caches the latest retrieved access token

func (*XSUAA) GetBearerToken

func (x *XSUAA) GetBearerToken() (authToken AuthToken, err error)

GetBearerToken authenticates to and retrieves the auth information from the provided XSUAA oAuth base url. The following path and query is always used: /oauth/token?grant_type=client_credentials&response_type=token. The gotten JSON string is marshalled into an AuthToken struct and returned. If no 'access_token' field was present in the JSON response, an error is returned.

func (*XSUAA) SetAuthHeaderIfNotPresent

func (x *XSUAA) SetAuthHeaderIfNotPresent(header *http.Header) error

SetAuthHeaderIfNotPresent retrieves a XSUAA bearer token and sets the 'Authorization' header on a given http.Header. If another 'Authorization' header is already present, no change is done to the given header.

Jump to

Keyboard shortcuts

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