HTTPS get session token using curl doesn't work (?)

I have tried the examples to use curl to get the session token using curl (Quickstart - Blues Developers)

On ubuntu / Windows 10 or wsl I get the same result, basically an empty line (note: email address and password are changed below but I am pretty sure they are correct)

brian@LAPTOP-70Q5CT1Q:/mnt/c/WINDOWS/system32$ curl --request POST --location “https://api.notefile.net/auth/login” --data ‘{“username":"brian@myemailaddress.com”, “password”:“mypassword!”}’
brian@LAPTOP-70Q5CT1Q:/mnt/c/WINDOWS/system32$

Invoking verbose
curl --verbose --request POST --location “https://api.notefile.net/auth/login” \

–data ‘{“username":"brian@myemailaddress.com”, “password”:“mypassword!”}’
Note: Unnecessary use of -X or --request, POST is already inferred.

  • Trying 34.197.91.124…
  • TCP_NODELAY set
  • Connected to api.notefile.net (34.197.91.124) port 443 (#0)
  • ALPN, offering h2
  • ALPN, offering http/1.1
  • successfully set certificate verify locations:
  • CAfile: /etc/ssl/certs/ca-certificates.crt
    CApath: /etc/ssl/certs
  • TLSv1.3 (OUT), TLS handshake, Client hello (1):
  • TLSv1.3 (IN), TLS handshake, Server hello (2):
  • TLSv1.2 (IN), TLS handshake, Certificate (11):
  • TLSv1.2 (IN), TLS handshake, Server key exchange (12):
  • TLSv1.2 (IN), TLS handshake, Server finished (14):
  • TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
  • TLSv1.2 (OUT), TLS change cipher, Client hello (1):
  • TLSv1.2 (OUT), TLS handshake, Finished (20):
  • TLSv1.2 (IN), TLS handshake, Finished (20):
  • SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
  • ALPN, server accepted to use h2
  • Server certificate:
  • subject: CN=*.notefile.net
  • start date: Aug 26 00:00:00 2020 GMT
  • expire date: Sep 25 12:00:00 2021 GMT
  • subjectAltName: host “api.notefile.net” matched cert’s “*.notefile.net”
  • issuer: C=US; O=Amazon; OU=Server CA 1B; CN=Amazon
  • SSL certificate verify ok.
  • Using HTTP2, server supports multi-use
  • Connection state changed (HTTP/2 confirmed)
  • Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
  • Using Stream ID: 1 (easy handle 0x7ffff54d3860)

POST /auth/login HTTP/2
Host: api.notefile.net
User-Agent: curl/7.58.0
Accept: /
Content-Length: 68
Content-Type: application/x-www-form-urlencoded

  • Connection state changed (MAX_CONCURRENT_STREAMS updated)!
  • We are completely uploaded and fine
    < HTTP/2 400
    < date: Wed, 12 May 2021 15:06:52 GMT
    < content-length: 0
    < vary: Origin
    <
  • Connection #0 to host api.notefile.net left intact

Seems to suggest I am getting the certificate but I don’t know enough about this stuff to figure out if that is indeed the case.

Regardless, I do not see a reply similar to the one in the example, namely
{“session_token”: “00000000000000000000000000000000”}

What am I doing wrong?

Thanks

I noticed the quotation marks (") in the terminal output you shared (shown below) are two different kinds, and ". It’s hard to see in most editors, but it makes a big difference to CURL.

brian@LAPTOP-70Q5CT1Q:/mnt/c/WINDOWS/system32$ curl --request POST --location “https://api.notefile.net/auth/login” --data ‘{“username":"brian@myemailaddress.com”, “password”:“mypassword!”}’
brian@LAPTOP-70Q5CT1Q:/mnt/c/WINDOWS/system32$

The bizarre quotation marks usually appear if you were to highlight the text and press Ctrl+C. As a sanity test, I clicked the COPY button on the webpage you shared, entered my own credentials, and I received a session token.

To ensure we are starting on the same footing, would you mind to go through the process once again, but being sure to press the COPY button?

Zach
I did indeed press copy and, just in case, I did it again. I suspect the weird quotation marks are an artifact of this forum’s paste. Just in case I retyped the line and got the same result.

However, you put me on the right track: I had reset my password but apparently it didn’t “take” until I logged out and logged back in again.

Apparently I was passing an old password.

Sometimes its hard to know if you are following the instructions right or otherwise screwing up.

Now I get a valid response.

Thanks!

1 Like

Zach
Sorry for the spam. Now that I can send a note to the Notecard via Notehub and curl, do you know the syntax for getting a note from Notehub?

I uploaded a Note from my Notecard with the example and I see it on Notehub

I tried to reverse engineer a “get” and ended up with this
curl --request POST --location ‘https://api.notefile.net/req
–header 'X-SESSION-TOKEN: ’
–data ‘{“req”:“note.get”,“file”:“sensors.qo”,
“product”:"",“device”:“dev:”}’

I get a reply
{“err”:“no notes available in queue {note-noexist}”}

But I can see the note on NoteHub

Thanks

Hi Brian,

I’m glad to hear you have been successful in sending Notes to Notehub.io!

To receive Notes, we have Notehub Routes, where you can create custom routing paths and specify your server as the endpoint.

notehub-routes-tab

Zack, thanks, I was aware of the routes aspect. That requires I set up a server or a cloud service of some sort. At least for testing (and potentially as an end use) I imagine something like an Android app to query your Notehub directly via HTTP.

It seems to make sense to me that if I can push a message from an app to the Notecard via Notehub (as I have now done successfully) I should be able to do the reverse and get a message from Notehub. Are you suggesting this is not the case?

Hi Brian,

We are finalizing this feature as we speak, and official documentation and support are coming soon!

I’ll report back to this thread with a link to the documentation, once it is available.

Zach
I actually made some progress.

Sometimes going for a 3 hour walk helps!

1 Like