我是新手,因此对您有所帮助。
我已经使用Google App Engine(节点)创建了可返回简单“ hello world”响应的应用程序/服务,请参阅https://resumetemplatesconverter.appspot.com/
我还有一个Polymer Web应用程序,该应用程序使用Firebase身份验证进行注册,登录,注销等。
问题是,配置Google App Engine应用程序/服务的最佳方法是什么,以便只有通过Polymer Web应用程序认证的用户才能使用它?
谢谢。
Firebase(授权服务器)将令牌(访问令牌)发送回客户端(浏览器)。
客户端现在使用该令牌向您的App Engine服务(资源服务器)发出请求。
您需要做的是检查令牌是否有效以及令牌是否有效,然后返回该秘密数据。
该的OAuth 2.0规范没有明确定义的访问令牌验证资源服务器和授权服务器之间的交互:
访问令牌属性和用于访问受保护资源的方法超出了本规范的范围,并由随附规范定义。
因此,对于您使用的每种身份验证服务(Google,Facebook,GitHub等),您都必须查找如何验证访问令牌。
例:
谷歌
请求(来自您的App Engine后端)
https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=XYZ123
响应
{
// These six fields are included in all Google ID Tokens.
"iss": "https://accounts.google.com",
"sub": "110169484474386276334",
"azp": "1008719970978-hb24n2dstb40o45d4feuo2ukqmcc6381.apps.googleusercontent.com",
"aud": "1008719970978-hb24n2dstb40o45d4feuo2ukqmcc6381.apps.googleusercontent.com",
"iat": "1433978353",
"exp": "1433981953",
// These seven fields are only included when the user has granted the "profile" and
// "email" OAuth scopes to the application.
"email": "[email protected]",
"email_verified": "true",
"name" : "Test User",
"picture": "https://lh4.googleusercontent.com/-kYgzyAWpZzJ/ABCDEFGHI/AAAJKLMNOP/tIXL9Ir44LE/s99-c/photo.jpg",
"given_name": "Test",
"family_name": "User",
"locale": "en"
}
您可以从后端服务器发出简单请求,但最好使用Google API客户端库之一
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句