我有一个angular 6应用程序,它向各种oauth2提供程序发出请求。我已经成功使用隐式授权类型成功地从这些提供商请求访问令牌(即将在授权码上进行操作)。现在,我正在尝试查找可以用来测试访问令牌的API端点列表。例如,向Google请求用户个人资料信息。
到目前为止,我已经能够从以下提供商处获取访问令牌:
Google(https://accounts.google.com)
OneDrive(https://login.live.com)
DropBox(https://www.dropbox.com)
有人知道我可以测试的上述任何一项(或任何其他oauth2提供程序)的任何可公开访问的API端点吗?
谢谢
答案 0 :(得分:0)
您可以在此处为Google回答问题。
您首先连接到Google API资源管理器网络应用程序:https://developers.google.com/apis-explorer/#p/
此网页可帮助您浏览许多Google API。因此,搜索名为 API Discovery Service 的API。它将回答一个提供有关其他Google API信息的API,例如可用的API,每种API的资源和方法详细信息。
因此,要获取每个API的列表,可以在此处调用此API发现服务的 list 入口点:https://www.googleapis.com/discovery/v1/apis?preferred=true
这是结果的开头:
{
"kind": "discovery#directoryList",
"discoveryVersion": "v1",
"items": [
{
"kind": "discovery#directoryItem",
"id": "abusiveexperiencereport:v1",
"name": "abusiveexperiencereport",
"version": "v1",
"title": "Abusive Experience Report API",
"description": "Views Abusive Experience Report data, and gets a list of sites that have a significant number of abusive experiences.",
"discoveryRestUrl": "https://abusiveexperiencereport.googleapis.com/$discovery/rest?version=v1",
"icons": {
"x16": "https://www.gstatic.com/images/branding/product/1x/googleg_16dp.png",
"x32": "https://www.gstatic.com/images/branding/product/1x/googleg_32dp.png"
},
"documentationLink": "https://developers.google.com/abusive-experience-report/",
"preferred": true
},
[...]
在上一个调用列出的每个API上, discoveryRestUrl 字段为您提供了一个URL,您可以在该URL上获取诸如相应API的入口点之类的信息。
例如,您可以在此处描述GMail API:https://www.googleapis.com/discovery/v1/apis/gmail/v1/rest
在输出中,从 auth 条目中提取OAuth2部分以获取范围:
"auth": {
"oauth2": {
"scopes": {
"https://mail.google.com/": {
"description": "Read, compose, send, and permanently delete all your email from Gmail"
},
"https://www.googleapis.com/auth/gmail.compose": {
"description": "Manage drafts and send emails"
},
"https://www.googleapis.com/auth/gmail.insert": {
"description": "Insert mail into your mailbox"
},
"https://www.googleapis.com/auth/gmail.labels": {
"description": "Manage mailbox labels"
},
"https://www.googleapis.com/auth/gmail.metadata": {
"description": "View your email message metadata such as labels and headers, but not the email body"
},
"https://www.googleapis.com/auth/gmail.modify": {
"description": "View and modify but not delete your email"
},
"https://www.googleapis.com/auth/gmail.readonly": {
"description": "View your email messages and settings"
},
"https://www.googleapis.com/auth/gmail.send": {
"description": "Send email on your behalf"
},
"https://www.googleapis.com/auth/gmail.settings.basic": {
"description": "Manage your basic mail settings"
},
"https://www.googleapis.com/auth/gmail.settings.sharing": {
"description": "Manage your sensitive mail settings, including who can manage your mail"
}
}
}
},
在说明中,您还将找到GMail API的端点:https://www.googleapis.com/gmail/v1/users/
最后,您可以通过OAuth2访问此API。
注意:与一个或几个API关联的每个作用域均在此处列出:https://developers.google.com/identity/protocols/googlescopes