我不知道為什么 Go SDK 上的 VerifyIDToken 會(huì)驚慌失措。我在 gin 的處理程序上使用了 VerifyIDToken,如下所示: r.GET("/idToken/:id", func(c *gin.Context) { // idToken := c.Param("id") opt := option.WithCredentialsFile("xxx-secret.json") app, err := firebase.NewApp(context.Background(), nil, opt) if err != nil { fmt.Println(fmt.Errorf("error initializing app: %v", err)) } client, err := app.Auth(context.Background()) if err != nil { fmt.Println("error getting Auth client: %v\n", err) fmt.Println(client) } idToken := c.Param("id") fmt.Println("idTaken = ", idToken) token, err := client.VerifyIDToken(context.Background(), idToken) if err != nil { fmt.Println("error verifying ID token: %v\n", err) } fmt.Println("Verified ID token: %v\n", token) })我已經(jīng)按如下方式調(diào)用了上面的 API: firebase.auth().onAuthStateChanged(function(user) { if (user) { user.getIdToken(/* forceRefresh */ true).then(function(idToken) { // Send token to your backend via HTTPS // ... axios .get('https://xx.xxx.com/idToken/' + idToken) .then(response => { this.response = response; console.log(response); if (response.data.update == "ok") { this.acceptOKresponse = true; } }) }).catch(function(error) { // Handle error });我完全不知道這種恐慌的原因。任何建議都非常受歡迎!謝謝你的建議。
Go SDK 上的 VerifyIDToken 驚慌失措
BIG陽(yáng)
2022-05-18 16:13:20