When a user clicks a button in your eApps application to authenticate via BMO, you need to redirect them to the BMO SSO page with proper query parameters.
protected void btnLoginWithBMO_Click(object sender, EventArgs e)
{
// Generate a unique state parameter for security (prevents CSRF attacks)
string state = Guid.NewGuid().ToString("N");
// Store state in session to verify on callback
Session["OAuthState"] = state;
// Your application's callback URL where BMO will redirect after successful auth
string returnUrl = "https://your-visa-app.com/auth/callback";
// Build the BMO eApps SSO URL
string bmoSsoUrl = $"https://sso-cte.test.fraedom-cloud.com/BmoSsoEapps.aspx?returnurl={HttpUtility.UrlEncode(returnUrl)}&state={HttpUtility.UrlEncode(state)}";
// Redirect user to BMO IdP
Response.Redirect(bmoSsoUrl);
}
public ActionResult LoginWithBMO()
{
// Generate a unique state parameter for security
string state = Guid.NewGuid().ToString("N");
// Store state in session to verify on callback
Session["OAuthState"] = state;
// Your application's callback URL
string returnUrl = "https://your-visa-app.com/auth/callback";
// Build the BMO eApps SSO URL
string bmoSsoUrl = $"https://sso-cte.test.fraedom-cloud.com/BmoSsoEapps.aspx?returnurl={HttpUtility.UrlEncode(returnUrl)}&state={HttpUtility.UrlEncode(state)}";
// Redirect user to BMO IdP
return Redirect(bmoSsoUrl);
}
<button onclick="loginWithBMO()" class="btn btn-primary">Login with BMO</button>
<script>
function loginWithBMO() {
// Generate state parameter (in production, get this from server)
var state = generateUUID();
// Your application's callback URL
var returnUrl = encodeURIComponent('https://your-visa-app.com/auth/callback');
// Build BMO eApps SSO URL
var bmoSsoUrl = 'https://sso-cte.test.fraedom-cloud.com/BmoSsoEapps.aspx?returnurl=' + returnUrl + '&state=' + encodeURIComponent(state);
// Redirect to BMO
window.location.href = bmoSsoUrl;
}
function generateUUID() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
</script>
https://sso-cte.test.fraedom-cloud.com/BmoSsoEapps.aspx?returnurl=<your_app_callback>&state=<random_state>https://identity-bmo-cte.test.fraedom-cloud.com/connect/authorizehttps://sso-cte.test.fraedom-cloud.com/bmo/callback?code=<auth_code>&state=<state>https://identity-bmo-cte.test.fraedom-cloud.com/connect/tokenClick the button below to test the BMO SSO flow using the dedicated eApps page: