cmd-johnson / ckb-cloud

Server-component for connecting ckb-next to the Cloud
GNU General Public License v3.0
4 stars 0 forks source link

always return invalid client_id #1

Closed lukedoomer closed 7 years ago

lukedoomer commented 7 years ago

client-side curl http://localhost:3007/clients/ ["{b516845c-d0bb-4985-b518-c45e8df4ce58}"]

curl http://localhost:3007/clients/{b516845c-d0bb-4985-b518-c45e8df4ce58}/keys/ "Invalid client_id"

curl http://localhost:3007/clients/b516845c-d0bb-4985-b51-c45e8df4ce58/keys/ "Invalid client_id"

server-side Local server started at socket /tmp/ckb-cloud REST-server listening on port 3007 Client connected: {b516845c-d0bb-4985-b518-c45e8df4ce58} Clients available: ["{b516845c-d0bb-4985-b518-c45e8df4ce58}"], requested: b516845c-d0bb-4985-b518-c45e8df4ce58 "Invalid client_id"

is it a bug?

cmd-johnson commented 7 years ago

Good catch, I only tested the endpoints using Postman, which automatically URL-encodes the curly brackets; curl doesn't do that. Try to replace the opening one with %7B and the closing one with %7D, that should do the trick.

curl uses URL globbing by default, which in this particular case makes curl interpret the request URL as if the brackets weren't there at all.

Instead of URL-encoding the brackets, you could also add -g to the curl-request to turn off URL globbing. That will send literal { and } to the server. (Although note that those are actually no safe characters in a URL and should generally be avoided.)

cmd-johnson commented 7 years ago

Also note that the current API is everything but stable, but every feedback is greatly appreciated!

lukedoomer commented 7 years ago

would you consider to remove { and } from the format of http url? I think using % or {} is kind of awkward. Pure character is much more resonable.

cmd-johnson commented 7 years ago

Granted, I don't like that format either, but for some reason it's the format Qt chose for UUID-strings. The IDs are generated and set by the ckb-cloud-client, I'll open an issue over there.

cmd-johnson commented 7 years ago

Okay, I just removed the curly braces from the string-representation of UUIDs. However the client-ID is only generated when adding the ckb-cloud client-effect in ckb, so you'll either have to remove the effect and add it again, or edit the effect properties and manually remove the brackets in the 'Client ID'-field. Note that you can name your client whatever you like, it doesn't have to be a UUID but can be any string.

lukedoomer commented 7 years ago

Excellent changes. Thank you.