Firebase(授权服务器)将令牌(访问令牌)发送回客户端(浏览器)。
客户端现在使用该令牌向您的应用程序引擎服务(资源服务器)发出请求。
你需要做的是检查令牌是否有效,如果有效,则返回该秘密数据.
The OAuth 2.0规范没有明确定义资源服务器和授权服务器之间用于访问令牌验证的交互:
访问令牌属性和用于访问受保护资源的方法超出了本规范的范围,由配套规范定义。
因此,对于您使用的每个身份验证服务(Google、Facebook、GitHub 等),您必须查找如何验证访问令牌。
Example:
Google
请求(来自您的应用程序引擎后端)
https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=XYZ123
Response
{
// 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 客户端库
请参阅此处了解有关的更多信息与后端服务器进行身份验证