Skip to main content
Question

Why cant i authenticate my app?! Oauth 2 or Session Auth


Im using the developer platform to build a zapier integration with an API that uses OAuth2 authorisation however am struggling. 

The API in question uses 4 bit of information to obtain an access token:

  • client_id
  • client_secret
  • username
  • password

The client_id and secret are fixed - they will be set in the Zapier integration and used every time. The username and password will need to be gathered by zapier then added to the request whenever someone wants to authenticate.

I can run a curl request and am successful in returning a result:

curl -XPOST -H 'Accept:application/json' -d 'grant_type=password&client_id=xxxxxxxx&client_secret=xxxxxxxxxxx&username=person@domain.com&password=MyPassword!' https://myAPIdomain.com/v1/auth/token

 

I have tried configuring this with both Oauthv2 and Session Auth however always get the same error "Invalid grant_type parameter or parameter missing"

My config for Session Auth:

HTTP Headers are content-type = application/x-www-form-urlencoded and accept = application/json. 

If i switch to code mode its the following:

 

const options = {

  url: 'https://myAPIdomain.com/v1/auth/token',

  method: 'POST',

  headers: {

    'content-type': 'application/x-www-form-urlencoded',

    'accept': 'application/json'

  },

  params: {

    'grant_type': 'password',

    'client_id': 'xxxxxxx',

    'client_secret': 'xxxxxxx',

    'username': bundle.authData.username,

    'password': bundle.authData.password

  },

  body: {

  }

}

return z.request(options)

  .then((response) => {

    response.throwForStatus();

    const results = response.json;

    // You can do any parsing you need for results here before returning them

    return {

      'sessionKey': results.sessionKey

    };

  });

What am i doing wrong?! Please help!

Did this topic help you find an answer to your question?

Did you ever get this going in the end?

I have an API I am trying to integrate which is an OAUTH2 password grant-type, and equally struggling. Any pointers?  Like you, my CURL or BASH works fine.


Hi I am able to authenticate users  using developer zapier paltform. How can i handle to initate this process from app end?
Like on button click I want to manage this whole auth flow. 
May you pleas guide us if you have any idea?

I have setup the callback url and currently from app end if I initate the process zapier is not giving me code in callback url instate it is giving me some zapier link with code and state and currently I am manually calling my callback url with code and state param from app end


Reply