I recently set up the Google OAuth hybrid server-side flow, which involves making an AJAX call to retrieve an access token. Upon successfully storing the token, I want the server to display content using a file named home.scala.html.
// This function is called when the client confirms the OAuth login dialog
function signInCallback(authResult) {
if (authResult['code']) {
$.ajax({
url: "http://localhost:9000/storeauthcode",
...
success: function(result) {
// Access token was saved
// Now redirect to the home area of the website
window.location.replace("http://localhost:9000/home");
},
error: function (xhr, status, error) {
// Handle error appropriately here
...
}
});
}
}
However, when everything works fine and I receive the token, the content rendered is just the template code from my home.scala.html file instead of being interpreted as HTML by the browser.
How can I make sure that the browser actually renders the home.scala.html file as HTML rather than plain text?
Also, should I be doing a redirect in this case or should the content be displayed on the same page? It seems a bit odd for the Google login window to close and then have the user wait to be redirected to the site.
What would be the best way to retrieve and display this content - through AJAX, AngularJS, or some other method?