【发布时间】:2017-03-01 01:02:24
【问题描述】:
通过 Google 帐户成功进行身份验证的每个人都可以通过 API Explorer 执行 API。
我想将通过 API Explorer 执行 API 的能力限制为仅限于某些用户。但与此同时,我的 Android 和 iOS 应用程序的所有用户都可以访问 API。
至少 Android 应用程序的安全性通过 Android 客户端 ID 和 SHA 指纹来促进。因此,这里的范围是不包括应用程序访问安全性。
【问题讨论】:
通过 Google 帐户成功进行身份验证的每个人都可以通过 API Explorer 执行 API。
我想将通过 API Explorer 执行 API 的能力限制为仅限于某些用户。但与此同时,我的 Android 和 iOS 应用程序的所有用户都可以访问 API。
至少 Android 应用程序的安全性通过 Android 客户端 ID 和 SHA 指纹来促进。因此,这里的范围是不包括应用程序访问安全性。
【问题讨论】:
还有,
endpoints.get_current_user()) 不在列表中,则在端点方法中引发 endpoints.UnauthorizedException。Python 示例代码:
if self.request_state.headers.get('x-referer') == "https://apis-explorer.appspot.com" and endpoints.get_current_user() not in MY_LIST:
raise endpoints.UnauthorizedException('Not Authorized')
【讨论】: