idetity-toolkit-go-cliet是 Go语言环境中的 GoogleidetityToolkit客户端库。
示例:
var cliet *gitkit.Clietfuc hadleSigI(w http.ResposeWriter, r *http.Request) { // If there is o valid sessio, check idetity tookit ID toke. ts := cliet.TokeFromRequest(r) toke, err := cliet.ValidateToke(ts) if err != il { // Not a valid toke. Hadle error. } // Toke is validate ad it cotais the user accout iformatio // icludig user ID, email address, etc. // Issue your ow sessio cookie to fiish the sig i.}fuc mai() { // Provide cofiguratio. gitkit.LoadCofig() ca also be used to load // the cofiguratio from a JSON file. cofig := &gitkit.Cofig{ ClietID: "123.apps.googleusercotet.com", WidgetURL: "https://localhost/gitkit", ServerAPIKey: "server_api_key", ServiceAccout: "123-abc@developer.gserviceaccout.com", PEMKeyPath: "/path/to/service_accout/private-key.pem", } var err error cliet, err = gitkit.New(cofig) if err != il { // Hadle error. } // Provide HTTP hadler. http.HadleFuc("/sigI", hadleSigI) // Start the server. log.Fatal(http.ListeAdServe(":8080", il))}
评论