开发者社区> 问答> 正文

Python oauth2lib和POST json验证参数

我想连接到一个使用oauth2的预订系统API,但是这个API的具体情况是,所有的方法,包括授权,都必须通过发送JSON有效负载的POST请求来调用。 我试图使用oauth库,但所有示例和文档都展示了如何使用标准授权方法。 如何在oauth2认证中传递自定义JSON POST ? 问题来源StackOverflow 地址:/questions/59466200/python-oauth2lib-and-post-json-auth-parameters

展开
收起
kun坤 2019-12-25 13:46:29 637 0
1 条回答
写回答
取消 提交回答
  • spring security oauth2默认的错误信息返回格式是xml,如果要返回json,可以在请求头中指定'Accept: application/json'。

    指定为json示例

    curl -i -L -H 'Accept: application/json' --data 'client_id=0000-0003-2736-8061&client_secret=5f63d1c5-3f08-4fa5-b066-fd985ffd0df7&grant_type=authorization_code&code=Q70Y3A&redirect_uri=https://developers.google.com/oauthplayground' 'http://api.sandbox-1.orcid.org/oauth/token'
    

    指定为xml示例

    curl -i -L -H 'Accept: application/xml' --data 'client_id=0000-0003-2736-8061&client_secret=5f63d1c5-3f08-4fa5-b066-fd985ffd0df7&grant_type=authorization_code&code=Q70Y3A&redirect_uri=https://developers.google.com/oauthplayground' 'http://api.sandbox-1.orcid.org/oauth/token'
    
    2019-12-26 13:57:54
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载