/// <summary> /// Gets the Salesforce authorization URL. The optional target parameter allows the app to redirect to /// a specified page after authorization; if the parameter is not specified, the app redirects to the current /// request's URL. /// </summary> /// <returns>The Salesforce authorization URL.</returns> public static string GetAuthorizationUrl(string targetUri = null) { return(Common.FormatAuthUrl( SalesforceService.GetAppSetting("Salesforce:Domain") + "/services/oauth2/authorize", ResponseTypes.Code, SalesforceService.GetAppSetting("Salesforce:ConsumerKey"), HttpUtility.UrlEncode(SalesforceOAuthRedirectHandler.GetAbsoluteRedirectUri()), DisplayTypes.Page, false, HttpUtility.UrlEncode(string.IsNullOrEmpty(targetUri) ? HttpContext.Current.Request.Url.AbsoluteUri : targetUri))); }
/// <summary> /// Processes the authentication callback from Salesforce. /// </summary> /// <param name="context">The HTTP context.</param> /// <returns>The asynchronous task.</returns> public override async Task ProcessRequestAsync(HttpContext context) { await SalesforceService.AcquireTokenByAuthorizationCodeAsync( context.Request.QueryString["code"], SalesforceOAuthRedirectHandler.GetAbsoluteRedirectUri()); string state = HttpUtility.UrlDecode(context.Request.QueryString["state"]); string redirectUrl = state == null ? "~/" : state; context.Response.Redirect(redirectUrl, false); }