Skip to content
This repository has been archived by the owner on Jun 16, 2020. It is now read-only.

Latest commit

 

History

History

http

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

HTTP client example

Example HTTP request using IAP authentication.

Description

This example shows manually using IAP tokens to authenticate an HTTP request.

One could also use an oauth2 client:

// error handling ommitted
package main

import (
    "golang.org/x/oauth2"
    iap "github.com/bakins/iap-token-source"
)

func main() {
    t, err := iap.New(MY-CLIENT-ID)
    c := oauth2.NewClient(context.Background(), t)
    // now use c as normal
}

The client-id is the oauth client_id in the credentials associated with your IAP configuration. See https://cloud.google.com/iap/docs/authentication-howto#authenticating_from_a_service_account