How to fix 'TypeError: this.isCallback is not a function' error for UserAgentApplication in msal.js - msal

using Msal v1.0.2, loginPopup is not working from iFrame.
trying to get the UserAgentApplication instance using client_id. its throwing an exception:
TypeError: this.isCallback is not a function
at Object.UserAgentApplication (UserAgentApplication.ts:228)
const myMSALObj = Msal.UserAgentApplication(msalConfig);
myMSALObj.loginPopup(["user.read"]).then(function (loginResponse) {
return myMSALObj.acquireTokenSilent(accessTokenRequest);
}).then(function (accessTokenResponse) {
const token = accessTokenResponse.accessToken;
}).catch(function (error) {
//handle error
});
sample from . 'Quickstart for MSAL JS' works fine but when I try to integrate Msal inside iFrame of my JavaScript plugin code, its not working.
working code from sample:
var myMSALObj = new Msal.UserAgentApplication(msalConfig);
myMSALObj.handleRedirectCallback(authRedirectCallBack);
myMSALObj.loginPopup(requestObj).then(function (loginResponse) {
acquireTokenPopupAndCallMSGraph();
}).catch(function (error) {
//Please check the console for errors
console.log(error);
});

there was a typo causing this exception: TypeError: this.isCallback is not a function at Object.UserAgentApplication (UserAgentApplication.ts:228)
fix: const myMSALObj = new Msal.UserAgentApplication(msalConfig);
That should solve this exception issue.

Related

Nextjs TypeError: "Cannot read property 'headers' of undefined", after update to nextjs 12.1.0

After update to Nextjs 12.1.0, when I call api via api route, the following error is returned. I'm using aws amplify.
The following error is returned in the CloudFront console:
My api route:
const handlerProducts = async (req: NextApiRequest, res:NextApiResponse) => {
const params = req.query;
try {
const { data } = await axios.get(URL, {
params,
});
res.status(200).send(data);
} catch (err: any) {
res.status(500).end();
}};
What could be causing this problem?
Thanks for all the help.
I downgraded next.js to 12.0.8 and it works again
While investigating possibly the same issue, I found https://github.com/serverless-nextjs/serverless-next.js/issues/2327
zhenjie states on GitHub: "Confirmed 12.0.8 works fine, and 12.0.9 does not work."

Possible unhandled promise rejection warning with useMutation

I'm getting an unhandled promise rejection error when I use useMutation with react native. Here's the code producing the issue:
const [createUser, { error, loading }] = useMutation(CREATE_USER_MUTATION);
Anytime my graphql server returns an error to the client I get an unhandled promise rejection error (screenshot below). I'm able to make it go away by adding an error handler like so, but it seems like a hack. Any thoughts? Am I doing something wrong or is this something that should be addressed by the apollo folks?
const [createUser, { error, loading }] = useMutation(CREATE_USER_MUTATION, {
onError: () => {}
});
Your createUser mutation is a promise you should handle error inside try catch block, or in upper scope inside apollo-link-error onError method.
const [createUser, { data, loading }] = useMutation(CREATE_USER_MUTATION, {
onError: (err) => {
setError(err);
}
});
With this we can access data with loading and proper error handling.

Axios catch will not trigger

I have a react app that the user will enter info into a redux form and the function is called. I have a axios post that will not catch an error. I'm not sure what this is happening.
export function vehicleformsubmit(props){
const input={
rfidtag: rfidtag.value,
vin: vin.value,
vehzone: vehzone.value
};
var request=axios.post(`http://localhost:9000/api/bmwvehicle/create`, input);
return function(dispatch){
request.then((response) =>{
dispatch(createVehicleSuccess(response.data, response.status));
}).catch((error) =>{
if(error.response){
dispatch(vehicleHaveError(true));
}
});
};
}
This is that I get back:
createError.js:16 Uncaught (in promise) Error: Request failed with
status code 500
at createError (createError.js:16)
at settle (settle.js:18)
at XMLHttpRequest.handleLoad (xhr.js:77)

Can't access laravel response from ajax library

// Edit: Hm...this is an firebug bug in firefox. On chrome it works...
I'm using Laravel 5.3 with Vue 2.0 and the axios ajax library.
Here is a test controller, where i return a response from laravel:
public function testMethod() {
return response('this is an error', 500);
}
Here is my ajax call:
http(`fetch-data`).then(response => {
const data = response.data;
console.log(data);
}).catch(error => {
console.log(error); // <- This doens't work, he show my nothing
alert(error);
});
The problem is, i need the error message which is returned from laravel into my client catch. But if i console.log them, he show me nothing. If i alert the error, he gives me the following message: Error: Request failed with status code 500.
Why can't i access something like error.statusCode, error.statusMessage?
Try
return response()->json('this is an error', 500);

Yahoo OAuth2 Error 95022

When trying to get a request token for an app, it gets the error:
Oops. Yahoo is unable to process your request. We recommend that you
contact the owner of the application or web site to resolve this
issue. [95022] Close
This is the code raising the error:
var main = angular.module("main", ["ngRoute"]);
main.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'partials/login.html',
controller: 'loginController'
})
});
main.controller("loginController", function ($scope) {
$scope.login = function () {
var clientID = "[redacted]";
window.location.href = "https://api.login.yahoo.com/oauth2/request_auth?client_id=" + clientID + "&redirect_uri=http://www.acleanpairofshorts.com&response_type=token&language=en-us";
};
});
You need to URL-encode the value of the redirect_uri parameter or else the arguments following that will be interpreted as part of that instead of the actual URL.

Resources