unofficial Active Directory Authentication Library for go.
go get github.com/orisano/go-adal
package main
import (
"context"
"io"
"log"
"os"
"github.com/orisano/go-adal"
)
const (
tenant = "common"
resource = "resource.example"
clientID = "xxxxxxxxxxxxxxxxx"
clientSecret = "xxxxxxxxxxxxxxxxx"
)
func main() {
ac, err := adal.NewAuthenticationContext(tenant)
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
client, err := ac.Client(ctx, resource, clientID, clientSecret)
if err != nil {
log.Fatal(err)
}
resp, err := client.Get("http://api.example/v1/resource")
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
io.Copy(os.Stdout, resp.Body)
}
Nao Yonashiro (@orisano)
MIT