I’ve set up an EasyAuth authentication with my Azure server for my Wisej web app. I’m using a javascript to access the token. I only need to retrieve the email claim to complete further user authentication inside my vb.net app. The script fires successfully on the server revealing the token in an alert, but I want to send the string to a method using <WebMethod>. I’ve been able to accomplish this in other parts of the app but I’m hitting a snag here, I suspect it’s something simple I’m missing. Here’s the javascript:
—————————————————–
Public Sub RunJavaScriptCode()
Try’——————— I also tried removing the Try/Catch but no joy
Application.Eval(”
var req = new qx.io.remote.Request(‘https://mywebsite.azurewebsites.net/.auth/me’, ‘GET’, ‘text/plain’);
req.addListener(‘completed’, function(e) {
alert(e.getContent());’———————–This works
var response = e.getContent();
App.LandingPage.GetToken(response);’——————This does not
});
// Send request
req.send();
“)
Catch ex As Exception
Console.WriteLine($”Error during interact authentication: {ex.Message}”)
End Try
End Sub
—————————————————————
Here’s basically the GetToken method which I’ve tried in both the Program.vb and LandingPage.vb locations:
—————————————————————
<WebMethod>
Public Sub GetToken(T As String)
MessageBox.Show(T, “GetToken”) ‘————–this does not fire
Dim ParsedT as String
‘Parse T to get the email – do stuff
Application.Session.UserEmail = ParsedT
End Sub
——————————————————————
I placed the RunJavaScriptCode call in the Program.vb to run first. I originally had the GetToken method in the Program.vb file as well but noted in a WiseJ Question that is might be best in a page, in this case the LandingPage. It is not called in either location despite the fact that I confirmed the javascript is retrieving the token since the alert is shown displaying the token. Oddly, it worked for a time with the GetToken method in the Program.vb but I tried to make the javascript method run async so somehow I messed it up. Removing my failed attempt at async stopped the WebMethod functionality. I’m not sure what is different now. You see I tried to make the call async/wait since the result of the Ajax call needs to complete before the program can process the email found in the token. Understanding why making the javascript method async caused it to lock up will likely be a second question after I get this back working.
I’m glad to send more info if needed.
Thanks!
Gerry
Thanks Levie,
Is it possible you could look at the async method? It still locks up in the javascript.
Gerry
I had trouble adding the attachment, here it is.
I sent both approaches I tried. I commented out the async approach but that is my true aim, since the internal user authentication relies on getting the user email and can’t proceed until its derived. The approach I used without using the async simply does not fire the app..GetToken method and the async method locks up when executing the javascript. As I mentioned, the published app properly returns the token.
Thanks for your assistance!
Gerry
Hi Gerald,
Can you send us a sample code that shows your concern in more detail.
Thanks,
Kevin(ITG)
Please login first to submit.