简体   繁体   English

Google OAuth2身份验证和PHP上的API

[英]Google OAuth2 authenticate and API on PHP

I have created a button that allows users to sign in with Google. 我创建了一个按钮,允许用户使用Google登录。

After the users choose their google accounts, I can get the following parameters as response from Google. 用户选择他们的Google帐户后,我可以从Google获得以下参数作为响应。

access tokens id_token expires_in token_type created 访问令牌id_token expires_in token_type已创建

How can I use these parameters to use services provide from Google? 如何使用这些参数来使用Google提供的服务?

For example, can I create buttons for user to go to the gmail boxes? 例如,我可以创建供用户转到gmail框的按钮吗?

If it is not the way, what are the uses of those token? 如果不是这样,那么这些令牌的用途是什么?

Using Google's tokens id you can get User's Information like Name Email. 使用Google的令牌ID,您可以获得诸如姓名电子邮件之类的用户信息。

You cant provide direct option to open Gmail. 您无法提供直接选项来打开Gmail。 It will prompt user to login 它将提示用户登录

You can refer this doc for more info Gmail scopes 您可以参考此文档以了解更多信息Gmail范围

For accessing Google services, you need the access_token . 要访问Google服务,您需要access_token When you are creating the authentication URL, you must specify all scopes - permissions (from this list ) you want to use in your application. 创建身份验证URL时,必须指定要在应用程序中使用的所有范围-权限(从此列表开始 )。 Then Google will ask the user for consent with delegating those permissions to your application. 然后,Google将征求用户同意,将这些权限委派给您的应用程序。 The access token you get will allow you to perform those actions. 您获得的访问令牌将允许您执行这些操作。

You can go through those Google API scopes and get an idea what you can do and what not. 您可以遍历这些Google API范围,并了解可以做什么和不可以做什么。 For example you cannot use the GMail GUI, but you can read, send, delete, and manage user's emails, send new emails and so. 例如,您不能使用GMail GUI,但是可以阅读,发送,删除和管理用户的电子邮件,发送新电子邮件等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM