有对 curl 命令熟的不?

2014-07-29 09:56:32 +08:00
 eggacher
curl -X POST -d "grant_type=password&username=george&password=123456" http://8tzpnrQXugOwaNN7j:d69CfLZ4@192.168.101.5:8000/o/token/

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

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

以下方式是不行的:
<form action="http://8tzpnrQXugOwaNN7j:d69CfLZ4@192.168.101.5: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要以怎样参数传递过去呢?
3294 次点击
所在节点    程序员
7 条回复
lijinma
2014-07-29 10:01:21 +08:00
去掉 type="application/x-www-form-urlencoded" 试试?
lijinma
2014-07-29 10:02:39 +08:00
错了,去掉 application/x-www-form-urlencoded 也没用,因为默认就是 application/x-www-form-urlencoded。。。
eggacher
2014-07-29 10:04:22 +08:00
@lijinma 试过了,不是这个问题。

<form action="http://8tzpnrQXugOwaNN7j:d69CfLZ4@192.168.101.5: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
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
2014-07-29 10:15:20 +08:00
httpie, httpie-oauth
bigfei
2014-07-29 11:02:15 +08:00
pmispig
2014-07-29 11:20:05 +08:00
如果按你后面的表单构建提交成功,那curl 的那个命令提交应该会出错啊

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/124998

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX