Getting connections with fetch

edited August 2018 in Social Login

Seems like this should be simple, but I always get a 401 unauthorized response. I am using the correct endpoint and my public and private keys for the username and password. I have also tried base64 encoding the username/password combination. Note I have removed the backticks around the template literal because they mess up the formatting of this post. Also, the fetch is node-fetch, since this must be run on a server.

fetch(${endpoint}/connections/${connection_token}.json,{headers:{"Authentication":"Basic " + username + ":" + password}})
.then(response => { console.log(response.ok); console.log(response.status); return response.json(); } )

Best Answer

  • edited August 2018 Answer ✓

    Hi Simon,

    the header is not Authentication but Authorization.

    Authorization: Basic dXNlcjpwYXNzd29yZA==

    The hash is obtained by base64 encoding public_key:private_key

    Sign In or Register to comment.