Forum Discussion

Matthias's avatar
Matthias
New Contributor III
2 years ago

Username / password auth via post request

We've got a service that needs authentication via Post/Put request with the following body:

```

{
"U":"someUsername",
"P":"someSecurePassword",
"L":"EN"
}
```
 
Now with the rest post snap, i can  store the data in a "basic auth" account, and use the following:
``` 
'{
"U":"' + account.username + '",
"P":"' + account.password + '",
"L":"EN"
}'
```
now reading the Rest Api documentation, it is pointing me to use the HTTP client - which i tried, but this doesn't seem to give this option? 

is there any way to accomplish the same thing with the HTTP client snap?
 

6 Replies

  • alchemiz's avatar
    alchemiz
    Contributor III

    Hi Matthias ,

    Good day, I don't know if this helps but you can also set basic authentication through the http header 
    e.g

    Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ (encoded base64 username:password)


    • Matthias's avatar
      Matthias
      New Contributor III

      well that's kindof the opposite of what i need
      the endpoint i need to connect to doesn't accept Basic auth - but requires the username / password to be provided via post body.

  • SpiroTaleski's avatar
    SpiroTaleski
    Valued Contributor

    Matthias 

    The HTTP Client Snap can use the Basic Authentication Account. 

    Did you try to reference the credentials in the "Raw entity" field within the snap? 

    BR, 

    Spiro Taleski

    • Matthias's avatar
      Matthias
      New Contributor III

      yeah i did - unfortunately to no avail, as "account." is unknown in the http client snap

       

      • SpiroTaleski's avatar
        SpiroTaleski
        Valued Contributor

        hmm.. if that's the case, then another option maybe is to store the credentials to an expression file and reference from there in the Http Client Snap.