api icon indicating copy to clipboard operation
api copied to clipboard

Multiple auth tokens were supplied

Open joshlsullivan opened this issue 1 year ago • 2 comments

Hi there, when I pass in a username and password, I'm getting the following message:

Error: Multiple auth tokens were supplied for the auth on this endpoint, but only a single token is needed.

Here is my code: sdk.auth(`${username}`, `${password}`)

Any ideas?

joshlsullivan avatar Sep 21 '22 16:09 joshlsullivan

Hey! Mind sharing your full code? The following works for me (and correctly 401s):

const sdk = require("api")("@developers/v2.0#1yl2ql5lb604m");

sdk.auth("user", "pass");
sdk
  .getAPISpecification({ perPage: "10", page: "1" })
  .then((res) => console.log(res))
  .catch((err) => console.error(err));

domharrington avatar Sep 21 '22 17:09 domharrington

                let username = req.body.username;
                let password = req.body.password
                const sdk = require('api')('@servicem8/v1.0#l4i1el85gxrx6');
                if (username && password){
                    sdk.auth(`${username}`, `${password}`)
                } else {
                    sdk.auth(accessToken)
                }
                let job = await sdk.getJobSingle({uuid: jobId})

joshlsullivan avatar Sep 21 '22 17:09 joshlsullivan

Sorry for the delay on this, but that error is being thrown because that operation has an OR auth setup with OAuth2 or Basic auth requirements and the library is currently only picking the OAuth 2 option.

I'm working now to get a fix for this into v5, currently slated to hit on Friday.

erunion avatar Oct 24 '22 23:10 erunion

I've got a fix for this in https://github.com/readmeio/api/pull/543 and it'll hit in our v5 release.

erunion avatar Oct 25 '22 21:10 erunion