如何验证Google ID令牌?

huangapple go评论103阅读模式
英文:

how to verify Google ID-token?

问题

我想用Go AppEngine后端验证Android用户,

我可以通过按照http://android-developers.blogspot.co.il/2013/01/verifying-back-end-calls-from-android.html在Android中轻松获取ID令牌

我如何验证令牌并获取有效载荷?是否有适用于此的Go包?

英文:

I want to authenticate Android users with a Go AppEngine backend,

I can easily get an ID-token in Android by following http://android-developers.blogspot.co.il/2013/01/verifying-back-end-calls-from-android.html

how can I verify the token and get the payload ? is there a Go package for this ?

答案1

得分: 3

我自己找到了解决方案,可以使用https://code.google.com/p/google-api-go-client/库的oauth2/v2包来验证ID令牌。

在使用AppEngine时,需要进行一些安装调整,我在http://golangtutorials.blogspot.co.il/2011/11/using-external-api-in-go-appengine.html找到了一些指示。

英文:

I found the solution myself, the ID-token can be verified with the oauth2/v2 package of the https://code.google.com/p/google-api-go-client/ library.

some installation tweaks are necessary for using it with AppEngine, I found some pointers at http://golangtutorials.blogspot.co.il/2011/11/using-external-api-in-go-appengine.html

答案2

得分: 1

我已经创建了一个golang包,可以在https://github.com/emanoelxavier/openid2go上获得,它可以在不需要任何安装调整的情况下完成这个任务。它也适用于其他的openID身份提供者,不仅仅是Google。它将获取签名密钥,验证令牌(发行者、受众、过期时间等),并将用户身份信息提供给您的应用服务流程。

英文:

I have created a golang package available @ https://github.com/emanoelxavier/openid2go that does exactly that without the need of any installation tweaks. It works for other openID identity providers as well, not just Google. It will fetch the signing keys, validate the token (issuer, audiences, expiration, etc) and make the user identity information available to your application service pipeline.

答案3

得分: 0

从链接的文档来看,这只是一个OAuth2令牌。
请查看https://developers.google.com/appengine/docs/go/users/overview#OAuth_in_Go,其中描述了如何使用OAuth进行用户身份验证。

英文:

Judging from the linked docs, this is just an OAuth2 token.
Try taking a look at https://developers.google.com/appengine/docs/go/users/overview#OAuth_in_Go, which describes using OAuth to authenticate users.

答案4

得分: 0

如果您愿意使用实验性功能,请使用Google Cloud Endpoints for Android。它具有内置的OAuth身份验证。

英文:

If you are willing to use an experimental feature, use google cloud endpoints for android.
It has builtin oauth authentication.

huangapple
  • 本文由 发表于 2013年4月24日 02:37:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/16176744.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定