cloudfoundry / go-uaa

API for UAA written in Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go-uaa Travis-CI godoc Report card

Overview

go-uaa is a client library for the UAA API. It is a go module.

Usage

Step 1: Add go-uaa As A Dependency

$ go mod init # optional
$ go get -u github.com/cloudfoundry-community/go-uaa
$ cat go.mod
module github.com/cloudfoundry-community/go-uaa/cmd/test

go 1.13

require github.com/cloudfoundry-community/go-uaa latest

Step 2: Construct and Use uaa.API

Construct a uaa.API by using uaa.New(target string, authOpt AuthenticationOption, opts ...Option):

$ cat main.go
package main

import (
	"log"

	uaa "github.com/cloudfoundry-community/go-uaa"
)

func main() {
	// construct the API
	api, err := uaa.New(
		"https://uaa.example.net",
		uaa.WithClientCredentials("client-id", "client-secret", uaa.JSONWebToken),
	)
	if err != nil {
		log.Fatal(err)
	}

	// use the API to fetch a user
	user, err := api.GetUserByUsername("test@example.net", "uaa", "")
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("Hello, %s\n", user.Name.GivenName)
}

Experimental

  • For the foreseeable future, releases will be in the v0.x.y range
  • You should expect breaking changes until v1.x.y releases occur
  • Notifications of breaking changes will be made via release notes associated with each tag
  • You should use go modules with this package

Contributing

Pull requests welcome.

About

API for UAA written in Go

License:Apache License 2.0


Languages

Language:Go 99.9%Language:Shell 0.1%