/// <summary> /// Validate that the application can make a request to authorize an organization user with Sky API. /// </summary> private async Task <ErrorViewModel> TestSkyApiAuthorization() { var response = await SkyApiAuthenticator.RequestSkyApiAuthorization(); if (response.IsSuccessStatusCode) { return(null); } var authContent = await response.Content.ReadAsStringAsync(); var authErrorMessage = ""; // The Sky API authorization endpoint returns a web page where a Blackbaud application user would provide authorization for this // application to access the Blackbaud application user's data. We manually parse the HTML returned from the Sky API authorization endpoint // and look for any error messages that would denote configuration issues with this application. var errorDetailsIndex = authContent.IndexOf("bbapi-error-developer-details-message"); if (errorDetailsIndex > -1) { authErrorMessage = authContent.Substring(authContent.IndexOf(">", errorDetailsIndex) + 1, 50).ToLower().Trim(); } if (authErrorMessage.StartsWith("invalid client_id")) { return(new ErrorViewModel { Error = "Application ID invalid", Description = "Sky API has indicated that the application ID is not valid for authorization. " + "Ensure that the configured application ID is correct." }); } if (authErrorMessage.StartsWith("invalid redirect_uri")) { return(new ErrorViewModel { Error = "Application callback URI invalid", Description = "Sky API has indicated that the application callback URI is not valid for authorization. " + "Ensure that the configured application callback URI is correct." }); } return(new ErrorViewModel { Error = "Sky API authorization request error", Description = "The attempt to test authorization against Sky API did not succeed and has produced an unexpected error." }); }
public ActionResult LogoutSkyApi() { SkyApiAuthenticator.Logout(); return(Redirect("/login")); }
public async Task <ActionResult> RefreshSkyApi() { await SkyApiAuthenticator.RefreshTokens(); return(Redirect("/login")); }
public async Task <ActionResult> LoginCallbackSkyApi(string code) { await SkyApiAuthenticator.RequestTokens(code); return(Redirect("/login")); }