uaaclientcredentials

package
v0.0.0-...-56f7de6 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2015 License: Apache-2.0, Apache-2.0 Imports: 8 Imported by: 0

README

#UAA Client Credentials This package provides a go implementation for the client credentials flow for CloudFoundry UAA. It will exchange a client id and a client secret for a bearer token.

##Usage

import (
	"github.com/krujos/uaaclientcredentials"
)

func main() {
	uaaURL, err := url.Parse("https://uaa.10.244.0.34.xip.io")
	if nil != err {
		panic("Failed to parse uaa url!")
	}

	creds, err := uaaclientcredentials.New(uaaURL, true, "my_client", "my_secret")
	if nil != err {
		panic("Failed to obtain creds!")
	}
	
	token, err := creds.GetBearerToken()
	if nil != err {
		panic(err)
	}
	
	consumer.DoSomething(token)

}
	

See watchman for a slightly less contrived example.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UAATokenResponse

type UAATokenResponse struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   int    `json:"expires_in"`
	Jti         string `json:"jti"`
	Scope       string `json:"scope"`
	TokenType   string `json:"token_type"`
}

UAATokenResponse is the struct version of the json /oauth/token gives us when we ask for client credentials.

type UaaClientCredentials

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

UaaClientCredentials provides a token for a given clientId and clientSecret. The token is refreshed for you according to expires_in

func New

func New(uaaURI *url.URL, skipSSLValidation bool, clientID string,
	clientSecret string) (*UaaClientCredentials, error)

New UaaClientCredentials factory

func (*UaaClientCredentials) GetBearerToken

func (creds *UaaClientCredentials) GetBearerToken() (string, error)

GetBearerToken returns a currently valid bearer token to use against the CF API. You should not cache the token as the library will handle updating it if it's expired. This API will return an empty string and an error if there was a problem aquiring a token from UAA

Jump to

Keyboard shortcuts

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