Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
package main
import (
cc ""
type SpecialClient struct {
func main() {
client := NewClient(
// the client will update its token if it's expired
resp, err := client.Get("http://some.remote.resource/path/to/resource")
if err != nil {
body, _ := ioutil.ReadAll(resp.Body)
defer resp.Body.Close()
// If response code is 200 it was successful
if resp.StatusCode == 200 {
fmt.Println("The request was successful. Response below:")
} else {
fmt.Println("Could not perform request to the endpoind. Response below:")
func NewClient(cid, csec string) *SpecialClient {
// this should match whatever service has given you
// client credential access
config := &cc.Config{
ClientID: cid,
ClientSecret: csec,
TokenURL: "http://some.remote.resource/token",
Scopes: []string{"scope:name"},
// you can modify the client (for example ignoring bad certs or otherwise)
// by modifying the context
ctx := context.Background()
client := config.Client(ctx)
return &SpecialClient{client}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.