我正在开发一个网络服务,我希望我的用户使用一些已知的身份验证提供程序(facebook、google 等)登录,而不是注册一个新用户。
我将以堆栈溢出作为此类服务的示例。
根据我阅读 O-Auth 教程的理解,流程应该是这样的:
1. A user log in for the first time to Stack Overflow
2. User is asked to log in via Google or Facebook.
3. Stack overflow redirects the user to Google along with Stack Overflow app ID and a Redirect URL (Callback)
4. Google ask the user: "Stack overflow wants to access your account" - allow/deny.
5. Assuming the user allowed, Google will redirect the user back to Stack Overflow, and will send a Token back to stack overflow servers (the Callback URL) as well as a client ID (unique google id)
6. If this client id does not exists, Stack overflow creates a new user in its database with this client id, if it does exists, it will just return the user's data (e.g. questions asked)
7. Using the saved TOKEN, stack overflow servers can grab information from Google (if needed) without the user interaction (since the user allowed access to Google)
这个流量准确吗?如果是这样,这是主要问题。
客户端
客户现在想要向/从 Stack Overflow 发送/接收信息(例如发布问题)。
- 客户端需要向 Stack 溢出服务器发送什么样的信息,以便他们确认这确实是用户?
服务器端
Stack如何溢出,验证这个用户?(即 Stack Overflow 会在用户身上保存什么样的信息来识别他?Google/Facebook ID?)
Stackoverflow 服务器想要从用户的 Google 帐户中获取信息(用户允许此操作),stackover flow 服务器需要向 Google 发送什么样的信息才能检索此信息。