V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
eggacher
V2EX  ›  程序员

有对 curl 命令熟的不?

  •  
  •   eggacher · 2014-07-29 09:56:32 +08:00 · 3283 次点击
    这是一个创建于 3552 天前的主题,其中的信息可能已经有所发展或是发生改变。
    curl -X POST -d "grant_type=password&username=george&password=123456" http://8tzpnrQXugOwaNN7j:[email protected]:8000/o/token/

    这是curl post的一条命令,用来提交OAuth验证的

    我用表单应该怎么实现呢?

    以下方式是不行的:
    <form action="http://8tzpnrQXugOwaNN7j:[email protected]:8000/o/token/" method="post" type="application/x-www-form-urlencoded">
    <input name="grant_type" type="hidden" value="password" />
    <input name="username" type="text" value="george" />
    <input name="password" type="password" value="123456" />

    <input type="submit" value="submit" />
    </form>

    提示"invalidate client"

    8tzpnrQXugOwaNN7j:d69CfLZ4要以怎样参数传递过去呢?
    7 条回复    2014-07-29 11:20:05 +08:00
    lijinma
        1
    lijinma  
       2014-07-29 10:01:21 +08:00
    去掉 type="application/x-www-form-urlencoded" 试试?
    lijinma
        2
    lijinma  
       2014-07-29 10:02:39 +08:00
    错了,去掉 application/x-www-form-urlencoded 也没用,因为默认就是 application/x-www-form-urlencoded。。。
    eggacher
        3
    eggacher  
    OP
       2014-07-29 10:04:22 +08:00
    @lijinma 试过了,不是这个问题。

    <form action="http://8tzpnrQXugOwaNN7j:[email protected]:8000/o/token/" method="post" type="application/x-www-form-urlencoded">
    <input name="grant_type" type="hidden" value="password" />
    <input name="client_id" type="hidden" value="8tzpnrQXugOwaNN7j" />
    <input name="client_secret" type="hidden" value="d69CfLZ4" />
    <input name="username" type="text" value="george" />
    <input name="password" type="password" value="123456" />

    <input type="submit" value="submit" />
    </form>

    改成这样就行了...Orz..

    我就很奇怪,curl协议里也实现了 OAuth么?
    582033
        4
    582033  
       2014-07-29 10:13:19 +08:00
    curl -v -X POST --data 'rant_tyle=xxx&username=xxx&password=xxx' http://xx.com

    更多请参照: http://yjiang.tk/?p=41
    ibudao
        5
    ibudao  
       2014-07-29 10:15:20 +08:00
    httpie, httpie-oauth
    bigfei
        6
    bigfei  
       2014-07-29 11:02:15 +08:00
    pmispig
        7
    pmispig  
       2014-07-29 11:20:05 +08:00
    如果按你后面的表单构建提交成功,那curl 的那个命令提交应该会出错啊
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1021 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 19:12 · PVG 03:12 · LAX 12:12 · JFK 15:12
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.