Skip to content

Latest commit

 

History

History
31 lines (25 loc) · 803 Bytes

README.md

File metadata and controls

31 lines (25 loc) · 803 Bytes

HTTP Digest Authentication

GoDoc

Simple digest auth

package main

import (
	"net/http"
    	"os"
	"github.com/jpfielding/go-http-digest/pkg/digest"
)

func main() {
    // helper to create the default-ish transport
    transport := digest.DefaultHTTPTransport()
    dt := digest.NewTransport("user", "pwd", transport)
    client := dt.NewHTTPClient()
    client.Jar, _ = cookiejar.New(nil)
    // SHA-256 requrired for mongodbgov.com
    res, _err_ := client.Get("https://cloud.mongodbgov.com/api/atlas/v1.0/groups/<proj>/clusters/<cluster-name>")
    io.Copy(os.Stdout, res.Body)
    if err != nil {
        panic(err)
    }
    defer res.Body.Close()
}