api
api copied to clipboard
Multiple auth tokens were supplied
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?
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));
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})
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.
I've got a fix for this in https://github.com/readmeio/api/pull/543 and it'll hit in our v5 release.