Missing or invalid Authorization requesting access token

Hi All,

I just signed up and was trying to get an access token but I keep getting an error. This is my code. Please ignore properties as they are built in features on my app. Can anyone suggest a fix here?

function(properties, context) {
    var username = properties.client_id;
var password = properties.client_secret;
var auth = 'Basic' + Buffer.from(username + ':' + password).toString('base64');
    let post = {
        uri: `https://${properties.environment.toLowerCase()}.dwolla.com/token`,
        method: 'POST',
            "Content-Type": "application/json",
            "Authorization" : auth
            "client_id": properties.client_id,
            "client_secret": properties.client_secret,
            "grant_type": properties.grant_type
        json: true
	let result = context.request(post);
	return {
        full_body: JSON.stringify(result.body)};

Hi @nocodeventure , It could be the body that is throwing off this request. I’d try removing the client_id and client_secret from the body and see if it works okay. Also, we do have a Node SDK that handles this specific request! Unless you’re wanting to leverage your own HTTP library. :slight_smile: Here’s another example using axios that fetches a token and calls the root of the API you can maybe use as a reference:

const axios = require("axios");
const querystring = require("querystring");

const k = process.env.KEY;
const s = process.env.SECRET;

const a = axios.create({
  auth: { username: k, password: s },
  headers: { "Content-Type": "application/x-www-form-urlencoded" }

  querystring.stringify({ grant_type: "client_credentials" })
  .then(r => {
    return axios.get("https://api.dwolla.com", {
      headers: {
        Accept: "application/vnd.dwolla.v1.hal+json",
        Authorization: `Bearer ${r.data.access_token}`
  .then(r => console.log(r.data))
  .catch(e => console.error(e.response.data));