I am using the dotnetopenauth library and I am trying to figure out how to change the call back url.
I am looking at the sample file
public partial class SignInWithTwitter : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
if (TwitterConsumer.IsTwitterConsumerConfigured) {
this.MultiView1.ActiveViewIndex = 1;
if (!IsPostBack) {
string screenName;
int userId;
if (TwitterConsumer.TryFinishSignInWithTwitter(out screenName, out userId)) {
this.loggedInPanel.Visible = true;
this.loggedInName.Text = screenName;
// In a real app, the Twitter username would likely be used
// to log the user into the application.
////FormsAuthentication.RedirectFromLoginPage(screenName, false);
}
}
}
}
protected void signInButton_Click(object sender, ImageClickEventArgs e) {
TwitterConsumer.StartSignInWithTwitter(this.forceLoginCheckbox.Checked).Send();
}
So this is all what is needed to send a request off to twitter( for webforms slightly different for mvc).
I would like to change the url that the response comes back too(I rather have a separate action result.
Now it seems like StartSignInWithTwitter() is where it sets the url.
/// <summary>
/// Prepares a redirect that will send the user to Twitter to sign in.
/// </summary>
/// <param name="forceNewLogin">if set to <c>true</c> the user will be required to re-enter their Twitter credentials even if already logged in to Twitter.</param>
/// <returns>The redirect message.</returns>
/// <remarks>
/// Call <see cref="OutgoingWebResponse.Send"/> or
/// <c>return StartSignInWithTwitter().<see cref="MessagingUtilities.AsActionResult">AsActionResult()</see></c>
/// to actually perform the redirect.
/// </remarks>
public static OutgoingWebResponse StartSignInWithTwitter(bool forceNewLogin) {
var redirectParameters = new Dictionary<string, string>();
if (forceNewLogin) {
redirectParameters["force_login"] = "true";
}
Uri callback = MessagingUtilities.GetRequestUrlFromContext().StripQueryArgumentsWithPrefix("oauth_");
var request = TwitterSignIn.PrepareRequestUserAuthorization(callback, null, redirectParameters);
return TwitterSignIn.Channel.PrepareResponse(request);
}
It seems to be hard coded to get the current request from context. is it possible to override this somehow without me actually changing this line of code and recompiling the .dll?
Edit For now I made changes to the .dll - I really don't like this way as now i got to support a custom version.
public static OutgoingWebResponse StartSignInWithTwitter(bool forceNewLogin) {
Uri callback = MessagingUtilities.GetRequestUrlFromContext().StripQueryArgumentsWithPrefix("oauth_");
return StartProcess(forceNewLogin, callback);
}
private static OutgoingWebResponse StartProcess(bool forceNewLogin, Uri callback)
{
var redirectParameters = new Dictionary<string, string>();
if (forceNewLogin)
{
redirectParameters["force_login"] = "true";
}
var request = TwitterSignIn.PrepareRequestUserAuthorization(callback, null, redirectParameters);
return TwitterSignIn.Channel.PrepareResponse(request);
}
public static OutgoingWebResponse StartSignInWithTwitter(bool forceNewLogin, Uri callback)
{
return StartProcess(forceNewLogin, callback);
}
Hopefully there is another way.