You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.
I am using FuelSoap with FuelAuth and running into an issue on setting up the client.
var FuelAuthClient = new FuelAuth({
clientId: clientId,
clientSecret: clientSecret,
authUrl: authOrigin,
authOptions: {
authVersion: 2
}
});
FuelAuthClient.getAccessToken()
.then(function (data) {
// data.accessToken = your token
// data.expiresIn = how long until token expiration
console.log(data);
var SoapClient = new FuelSoap(FuelAuthClient);
SoapClient.retrieve(
'Email',
["ID", "Name", "Subject", "CategoryID", "EmailType"],
options,
function (err, response) {
if (err) {
// error here
console.log(err);
return;
}
// response.body === parsed soap response (JSON)
// response.res === full response from request client
console.log(response.body);
}
)
})
.catch(function (err) {
console.log(err);
});
The issue I am facing is in the FuelSoap initialization where it checks to see if its an instance of FuelAuth.
var authOptions = options && options.auth || {};
// use fuel auth instance if applicable
if(authOptions instanceof FuelAuth) {
this.AuthClient = authOptions;
} else {
try {
this.AuthClient = new FuelAuth(authOptions);
} catch (err) {
throw err;
}
}```
It looks like this line `var authOptions = options && options.auth || {};` is creating an empty object, expecting that `options.auth` exists. Well, when using the `FuelAuth` object, thats not the case so it defaults `authOptions = {}`.
This causes the `if(authOptions instanceof FuelAuth) {` to return false and it tries to initialize `FuelAuth` using the `authOptions` which is an empty object. This throws an error in `FuelAuth` about `Error: clientId or clientSecret is missing or invalid`.
To summarize, `if(authOptions instanceof FuelAuth) {` returns false when using `FuelAuth` because `options.auth` doesn't exist which causes `authOptions` to be set to an empty object.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I am using FuelSoap with FuelAuth and running into an issue on setting up the client.
The issue I am facing is in the
FuelSoap
initialization where it checks to see if its an instance ofFuelAuth
.The text was updated successfully, but these errors were encountered: