200错误:使用Parse和LiveCode登录时缺少用户名 [英] 200 error: missing username when logging in using Parse and LiveCode

查看:101
本文介绍了200错误:使用Parse和LiveCode登录时缺少用户名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过LiveCode登录到Parse,但始终收到此错误:

I am trying to login to Parse through LiveCode but keep getting this error:

{代码":200,错误":缺少用户名"}

{"code":200,"error":"missing username"}

我已经能够创建用户,甚至可以验证用户的电子邮件(通过Parse中的REST API),但是当我尝试登录时,总是出现错误. 我认为JSON格式或GET调用有问题,但我无法弄清楚.

I have been able to create users, even validate user's email (through the REST API in Parse) but when I try to login I keep getting an error. I think there is something wrong with my JSON formatting or the GET call but I can't figure it out.

command mainLogin
 local tLoginA, tLoginJson, tReturn, tLogin

 setHeaders
 put fld "username" into tLoginA [ "username" ]
 put the cPassword of fld "password" into tLoginA [ "password" ]
 put urlEncode ( JSON_stringified ( tLoginA ) ) into tLogin
 put urldecode ( tLogin ) --testing 

 get url ( "https://api.parse.com/1/login?" & tLogin )
 put it  --testing
 put JSON_parsed ( it ) into tReturn 
 if ( tReturn [ "error" ] <> empty ) then 
      answer "Please try again: " & tReturn [ "error" ]
 end if
 if ( tReturn [ "sessionToken" ] is NOT empty ) then 
      //user logged in successfully
      put tReturn [ "sessionToken" ] into sSessionToken
      put tReturn [ "objectid" ] into sObjecteID
      answer "Welcome " && tLoginA [ "username" ]
      mainClearFields
 end if
end mainLogin

函数JSON_parsed()JSON_stringified()来自Andreas Rozek的JSON库.

The functions JSON_parsed() and JSON_stringified() are from a JSON library by Andreas Rozek.

更新

我在登录时从Parse.com REST API文档中提取了此信息:

I pulled this from the Parse.com REST API documentation on logging in:

允许用户注册后,以后需要让他们使用用户名和密码登录到其帐户.为此,请将GET请求发送到/1/login终结点,并将用户名和密码作为URL编码参数...

After you allow users to sign up, you need to let them log in to their account with a username and password in the future. To do this, send a GET request to the /1/login endpoint with username and password as URL-encoded parameters...

从概念上讲,我无法使用它.

I get that conceptually but I can't get it to work.

感谢Mark的评论.我看到我正在使用Post标头处理程序,该处理程序添加了Content-Type: application/json,但变化不大.根据Parse.com的文档,GET动词是正确的(我更改了代码以显示新的标头处理程序).

Thanks Mark for your comment. I see that I was using the Post header handler which has the Content-Type: application/json added but that doesn't change much. According to the Parse.com docs the GET verb is the proper one (I changed the code to show the new header handler).

推荐答案

根据文档:使用用户名和密码作为URL编码参数,将GET请求发送到/1/登录端点"

According to the docs: "send a GET request to the /1/login endpoint with username and password as URL-encoded parameters"

尝试以下操作;

put "username=" & urlEncode("YourUser") & "&password=" & urlEncode("YourPass") into tLogin
get url ( "https://api.parse.com/1/login?" & tLogin )

这篇关于200错误:使用Parse和LiveCode登录时缺少用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆