如何使用 Devise 从终端使用 cURL 验证我的 Ruby on Rails 应用程序?
我想:
curl --user email:password http://domain.bla/api/auth/sign_in
并正在回应:
您要查找的页面不存在。
这对我有用:
curl -XPOST -v -H 'Content-Type: application/json' http://domain/api/v1/auth/sign_in -d '{"email": "[email protected] /cdn-cgi/l/email-protection", "password": "password" }
所以我得到了回复(如下所示,只是重要的部分):
< access-token: lW1c60hYkRwAinzUqgLfsQ
< token-type: Bearer
< client: W_xCQuggzNOVeCnNZbjKFw
< expiry: 1426610121
< uid: [email protected] /cdn-cgi/l/email-protection
然后我可以使用之前从上述请求中获得的客户端和令牌来验证令牌,我这样做:
curl -XGET -v -H 'Content-Type: application/json' -H 'access-token: lW1c60hYkRwAinzUqgLfsQ' -H 'client: W_xCQuggzNOVeCnNZbjKFw' -H "uid: [email protected] /cdn-cgi/l/email-protection" http://domain/api/v1/auth/validate_token
结果 :
{"success":true,"data":{"id":3,"provider":"email","uid":"[email protected] /cdn-cgi/l/email-protection","firstname":null,"lastname":null,"email":"[email protected] /cdn-cgi/l/email-protection"}}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)