我收到了一个 Hirevue 链接以响应我提交的工作申请,我正在处理该 URL 页面发出的 HTTP 请求。在不泄露个人信息的情况下,我无法提供该页面的 URL,也无法提供我所询问的请求发送到的 URL。因此,我意识到这会限制您能够提供的帮助/建议。
使用我的浏览器的开发工具,我发现一个 GET 请求被发送到这个 URL(为了隐私我已经编辑)以检索一个 JSON 文件(包含个人数据)。在请求标头中有一个授权标头,
Authorization: Bearer TOKEN_VALUE
.
据我了解,这意味着 JSON 文件受 OAuth 2.0 协议保护,并且 Bearer 授权方案用于传输不记名令牌以获取对 JSON 文件的访问权限1, 2。因此,如果不在 Authorization 标头字段中指定正确的持有者令牌,似乎就无法访问 JSON 文件。
当我发送带有空授权标头的 GET 请求(即
Authorization:
)时,我仍然能够访问 JSON 文件。
我正在使用下面的 python 脚本发送请求:
def get_json(url, auth_token=None):
# authorization header: scheme is Bearer token
response = requests.get(url, auth=auth_token)
try:
return response.json()
except JSONDecodeError:
print(f"Response to GET request:\n\n{response.content}\n\nExpected Reponse: a JSON string")
if __name__ == "__main__":
# auth token type and token value for API GET request
my_autho = ('', '')
# redacted URL for my privacy
url = "https://COMPANY.hirevue.com/interviews/INTERVIEW_CODE"
data = get_json(url, my_autho)
print(data)
当我从 GET 请求中省略授权标头(即
get_json(url)
)时,我被发送到 404 页面。因此,当我发送空标题时,我会期待同样的事情。
也就是说,我希望引发 JSONDecodeError 异常(被
get_json
捕获):
Response to GET request:
b'\n\n<html>\n <head>\n <title>Error 404: Not found | HireVue</title>\n <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\n <meta http-equiv="X-UA-Compatible" content="IE=7; IE=8; IE=9" />\n <link\n href="https://static.hirevue.com/static/14b0bc1/fonts/Inter-3.15/inter.css"\n
rel="stylesheet"\n />\n <link rel="stylesheet" type="text/css" href="https://static.hirevue.com/static/14b0bc1/css/build/bootstrap/bootstrap.css">\n
<style type="text/css">\n body {\n text-align:center;\n font-family: Arial, Helvetica, Sans-Serif;\n }\n </style>\n </head>\n <body>\n <h1>Oops! We couldn\'t find that Page!</h1>\n <h3>Error 404</h3>\n <p>Please go back and try again.</p>\n <img src="https://static.hirevue.com/static/14b0bc1/img-new/hv-logo-color.png" alt="HireVue" border="0">\n </body>\n</html>\n'
Expected Reponse: a JSON string
但是如前所述,我的实际输出是 JSON 字符串。那么为什么我仍然可以在没有令牌的情况下访问受 OAuth-2.0 保护的 JSON 文件?
参考资料: