如何找到接受 oauth2 令牌的 API 个端点
How to find API endpoints that accept oauth2 tokens
我有一个 angular 6 应用程序,它向各种 oauth2 提供程序发出请求。我已经成功地使用隐式授权类型从这些提供者请求访问令牌(即将处理授权代码)。现在,我正在尝试查找可以用来测试访问令牌的 API 端点列表。例如,从 Google.
请求用户个人资料信息
到目前为止,我已经能够从以下提供者处获得访问令牌:
Google (https://accounts.google.com)
阿尼利斯特 (http://anilist.co)
OneDrive (https://login.live.com)
DropBox (https://www.dropbox.com)
有谁知道我可以测试的任何上述(或任何其他 oauth2 提供商)的可公开访问的 API 端点?
谢谢
这里是您如何回答 Google 的问题。
您首先连接到 Google API 资源管理器 Web 应用程序:https://developers.google.com/apis-explorer/#p/
此网页可帮助您浏览许多 Google API。因此,搜索名为 API 的 API 发现服务 。它将回答 API 提供有关其他 Google API 的信息,例如可用的 API、资源和方法详细信息每个 API.
因此,要获取每个 APIs 的列表,您可以在此处调用此 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,您可以在其中获取信息,例如相应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
我有一个 angular 6 应用程序,它向各种 oauth2 提供程序发出请求。我已经成功地使用隐式授权类型从这些提供者请求访问令牌(即将处理授权代码)。现在,我正在尝试查找可以用来测试访问令牌的 API 端点列表。例如,从 Google.
请求用户个人资料信息到目前为止,我已经能够从以下提供者处获得访问令牌:
Google (https://accounts.google.com)
阿尼利斯特 (http://anilist.co)
OneDrive (https://login.live.com)
DropBox (https://www.dropbox.com)
有谁知道我可以测试的任何上述(或任何其他 oauth2 提供商)的可公开访问的 API 端点?
谢谢
这里是您如何回答 Google 的问题。
您首先连接到 Google API 资源管理器 Web 应用程序:https://developers.google.com/apis-explorer/#p/
此网页可帮助您浏览许多 Google API。因此,搜索名为 API 的 API 发现服务 。它将回答 API 提供有关其他 Google API 的信息,例如可用的 API、资源和方法详细信息每个 API.
因此,要获取每个 APIs 的列表,您可以在此处调用此 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,您可以在其中获取信息,例如相应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