func (o *oauthReceiver) killWhenReady(n net.Conn, s http.ConnState) {
	if o.killMeNow && s.String() == "idle" && o.mainClient == n.RemoteAddr().String() {
		o.doneChan <- nil
	}
}
Cleanly exit the HTTP server.
package config
import (
	"bytes"
	"context"
	"encoding/json"
	"fmt"
	"html/template"
	"log"
	"net"
	"net/http"
	"net/url"
	"strings"
	"time"
	"golang.org/x/oauth2"
	"golang.org/x/oauth2/google"
)
const (
	googleTokenURL      = "https://www.googleapis.com/oauth2/v4/token"
	oauthEmailScope     = "https://www.googleapis.com/auth/userinfo.email"
	serverStateTokenLen = 60
)
var oauthScopes = []string{oauthEmailScope}
type iapOAuthResponse struct {
	AccessToken  string `json:"access_token,omitempty"`
	RefreshToken string `json:"refresh_token,omitempty"`
	Type         string `json:"token_type,omitempty"`
	Expires      int    `json:"expires_in,omitempty"`
	IDToken      string `json:"id_token,omitempty"`
}
type oauthReceiver struct {
	port         int
	clientState  string
	killMeNow    bool
	mainClient   string
	doneChan     chan error
	callback     func(*oauth2.Token, *oauth2.Config, string) (string, error)
	clientId     string
	clientSecret string
}