API Authentication

CliveC
CliveC W/ Alumni Posts: 12 Security Scout

Hi,

So I am a noob to API's and I bet that I am just doing something stooooooopid... but I need some help nonetheless....

I am stuck right at the beginning at authentication, using the below with an error (I know the clever people will help me to correct this):

$ curl -L -v --http2 --request POST 'https://eu1.psb.fsapi.com/mp/v1/authenticate/login' \

> --header 'X-API-Key: my-API-Key' \

> --header 'Content-Type: application/json' \

> --header '{

> "username":"my-PSB-email",

> "password":"my-PSB-password"

> } '

*  Trying 34.255.221.142:443...

* TCP_NODELAY set

* Connected to eu1.psb.fsapi.com (34.255.221.142) port 443 (#0)

* ALPN, offering h2

* ALPN, offering http/1.1

* successfully set certificate verify locations:

*  CAfile: none

 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, Change cipher spec (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=eu1.psb.fsapi.com

* start date: Sep 24 00:00:00 2019 GMT

* expire date: Oct 24 12:00:00 2020 GMT

* subjectAltName: host "eu1.psb.fsapi.com" matched cert's "eu1.psb.fsapi.com"

* 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 0x5635421f4b90)

> POST /mp/v1/authenticate/login HTTP/2

> Host: eu1.psb.fsapi.com

> user-agent: curl/7.67.0

> accept: */*

> x-api-key: my-API-key

> content-type: application/json

> {

> "username":"my-PSB-mail",

> "password":"my-PSB-password"

> } 

* Connection state changed (MAX_CONCURRENT_STREAMS == 128)!

* HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)

* stopped the pause stream!

* Connection #0 to host eu1.psb.fsapi.com left intact

curl: (92) HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)

Best Answer

Answers

  • PetriKuikka
    PetriKuikka W/ Member Posts: 236 Threat Terminator

    Hi @CliveC,

    with a quick look it looks that you are posting the username and password in header and not as the body. And they should be part of the body of the POST message like:

    { username: 'your-username', password: 'your-password' }

    Petri

This discussion has been closed.