使用OAuth 2连接法国PISTE API遇401错误,请求Token失败求助
无法通过OAuth 2连接法国PISTE API获取Token的问题
我正尝试通过OAuth 2连接法国行政机构提供的PISTE API,但无法成功。我的最终目标是通过urllib3从LEGIFRANCE和JUDILIBRE API获取合法信息,但目前连使用cURL请求Token都无法实现。
操作步骤
1. 创建账户并编辑应用
- 参考官方用户指南
- 要访问LEGIFRANCE和JUDILIBRE,必须选择对应API并同意服务条款(完成后界面截图:配置完成界面)
2. 尝试获取Token
我在bash脚本中执行了以下命令:
# auth_url='https://sandbox-oauth.piste.gouv.fr/api/oauth/authorize' token_url='https://sandbox-oauth.piste.gouv.fr/api/oauth/token' client_id='here_is_my_ID' key='here_is_my_key' curl -k -v -H 'content-type: application/x-wwww-form-urlencoded' -d 'grant_type=client_credentials&client_id='$client_id'&client_secret='$key'&scope=openid' -X POST $token_url
服务器返回:
<TITLE>401 Authorization Required</TITLE> </HEAD><BODY> <H1>Authorization Required</H1> This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.<P>
我不知道该如何解决这个问题,请求帮助。
内容的提问来源于stack exchange,提问作者MadBleiz
相关产品推荐
相关产品推荐

