一大坨GoogleAPI的学习笔记之二(oAuth2.0总结)
2013-07-30 22:10
267 查看
本文地址:/article/2696008.html,转载需注明。
本文只针对本地应用,其他应用类型可能有不同。
URL 格式
需要注意的是该地址是https而不是http,非加密请求是被拒绝的。
参数:
一个授权链接实例:
授权页面:
总之,如果要请求授权的话就让用户在浏览器打开这个这个链接(传入相应参数),然后获取到该请求的返回值就行了。
Scopes available for the Drive API are:
To request access using OAuth 2.0, your application needs the scope information, as well as information that Google supplies during application registration (such as the client ID and/or the client secret).
The scope for IMAP and SMTP access is
本文只针对本地应用,其他应用类型可能有不同。
URL 格式
需要注意的是该地址是https而不是http,非加密请求是被拒绝的。
Endpoint | Description |
---|---|
https://accounts.google.com/o/oauth2/auth | 获取access token的第一个请求。其负责处理活跃session,验证用户。该请求的结果包括access tokens, refresh tokens, and authorization codes. |
Parameter | Values | Description |
---|---|---|
response_type | code | 相应类型,本地应用使用的值应为"code" |
client_id | the client_idobtained from theAPIs Console | Indicates the client that is making the request. The value passed in this parameter must exactly match the value shown in the APIs Console. |
redirect_uri | one of theredirect_urivalues registered at the APIs Console | 接受响应的地址,该地址必须跟APIs Console 中注册的地址完全一样(including the http or https schemes, case, and trailing '/').可以是 urn:ietf:wg:oauth:2.0:oob或 http://localhostport. See choosing a redirect_uri for more details. |
scope | 该参数表明了应用请求的权限种类 | 这些权限会在授权页展示给用户。(之后会详细说明这个参数) |
state | any string | Indicates any state which may be useful to your application upon receipt of the response. The Google Authorization Server roundtrips this parameter, so your application receives the same value it sent. |
login_hint | email addressor subidentifier | When your application knows which user it is trying to authenticate, it may provide this parameter as a hint to the Authentication Server. Passing this hint will either pre-fill the email box on the sign-in form or select the proper multi-login session, thereby simplifying the login flow. |
''' https://accounts.google.com/o/oauth2/auth? scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.file+ https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcalendar+ https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive+ https%3A%2F%2Fmail.google.com+ https%3A%2F%2Fwww.google.com%2Fm8%2Ffeeds& redirect_uri=http://localhost:8888& response_type=code& client_id=53354213461.apps.googleusercontent.com '''
授权页面:
总之,如果要请求授权的话就让用户在浏览器打开这个这个链接(传入相应参数),然后获取到该请求的返回值就行了。
Google Drive scopes
Scopes available for the Drive API are:Scope | Meaning |
---|---|
https://www.googleapis.com/auth/drive.file | Per-file access to files created or opened by the app |
https://www.googleapis.com/auth/drive | Full, permissive scope to access all of a user's files. Request this scope only when it is strictly necessary. Tokens with scope https://docs.google.com/feedsare accepted and treated the same as tokens with scope https://www.googleapis.com/auth/drive. |
https://www.googleapis.com/auth/drive.apps.readonly | Allows apps read-only access to the list of Drive apps a user has installed. |
https://www.googleapis.com/auth/drive.readonly | Allows read-only access to file metadata and file content |
https://www.googleapis.com/auth/drive.readonly.metadata | Allows read-only access to file metadata, but does not allow any access to read or download file content |
https://www.googleapis.com/auth/drive.install | Special scope used to let users approve installation of an app |
https://www.googleapis.com/auth/drive.appdata | Allows access to the Application Data folder |
https://www.googleapis.com/auth/drive.scripts | Allows access to Apps Script files |
Google Calendar scopes
Scope | Meaning |
---|---|
https://www.googleapis.com/auth/calendar | read/write access to Calendars |
https://www.googleapis.com/auth/calendar.readonly | read-only access to Calendars |
Gmail scopes
The scope for IMAP and SMTP access is https://mail.google.com/.
Google Contacts scopes
Scope | Meaning |
---|---|
https://www.google.com/m8/feeds | read/write access to Contacts and Contact Groups |
相关文章推荐
- 一大坨GoogleAPI的学习笔记之一(oAuth2.0)
- 项目管理学习笔记之二范围管理过程总结
- Angularjs 学习笔记总结之二
- 7089-1.Python机器学习:监督学习笔记—代码总结
- PHP学习笔记之二
- java 十二十三天学习笔记总结
- 黑马程序员_学习笔记6注解的总结
- H.265/HEVC学习笔记之二:码流分析
- Lucene学习总结之二:Lucene的总体架构
- 【学习笔记】Unity StartCoroutine 中 yield return 总结
- JAVA学习笔记----第一章的总结
- aps.net2.0配置学习笔记总结1
- 学习 OAuth2.0 笔记( 一 )
- C++学习笔记-类相关问题总结
- 学习设计模式笔记(二)部分总结
- Linux运维学习笔记之二:常用命令2
- Java学习笔记第十天:2_修饰符的概述和总结
- 项目管理学习笔记之八.课程总结
- 深度学习笔记之关于总结、展望、参考文献和Deep Learning学习资源(五)
- 从零开始系列-R语言基础学习笔记之二 数据结构(一)