Exemplo n.º 1
0
func jsSignInGoogleHandler(ctx *app.Context) {
	code := ctx.RequireFormValue(oauth2.Code)
	redir := "postmessage" // this is the redir value used for G+ JS sign in
	d := data(ctx)
	googleApp := d.opts.GoogleApp.Clone(ctx)
	token, err := googleApp.Exchange(redir, code)
	if err != nil {
		panic(err)
	}
	user, err := userFromGoogleToken(ctx, googleApp, token)
	if err != nil {
		panic(err)
	}
	ctx.MustSignIn(asGondolaUser(user))
	writeJSONEncoded(ctx, user)
}