Yahoo BBAuthen с сеансом аутентификации? - PullRequest
1 голос
/ 10 сентября 2009

Я пытаюсь использовать Yahoo BBA с моим веб-приложением, но у меня всегда возникают проблемы с аутентификацией Yahoo.

Вот мой странный код:

YahooLogin.aspx.cs

protected void ImageButtonYahoo_Click(object sender, ImageClickEventArgs e)
{
    // Create an instance of Yahoo.Authentication  
    Yahoo.Authentication auth = new Authentication(strApplicationID, strSecret);
    // Redirect the user to the use sign-in page  
    Response.Redirect(auth.GetUserLogOnAddress().ToString());
}

И URL конечной точки: BBAuth.cs

protected void Page_Load(object sender, EventArgs e)
{
    bool success = false;
    // Retrieve this user's authentication object we've stored in the session state  
    Yahoo.Authentication auth = Session["Auth"] as Yahoo.Authentication;

    if (auth == null)
    {
        // We have a problem with the current session, abandon and retry  
        Session.Abandon();
        Response.Redirect("ErrorPage.aspx");
    }
    // Check if we are returning from login  
    if (Request.QueryString["token"] != null && Request.QueryString["token"].Length > 0)
    {
        // Make sure the call is valid  
        if (auth.IsValidSignedUrl(Request.Url) == true)
        {
            success = true;
            // Save the user token. It is valid for two weeks  
            auth.Token = Request.QueryString["token"];
        }
    }

    // Redirect if we succeeded  
    if (success == true)
    {
        Response.Redirect("Default.aspx");
    }
    else
    {
        Response.Redirect("SignInError.aspx");
    }
}

Response.Redirect("ErrorPage.aspx"); всегда выполняется, кто-то может сказать мне, что отсутствует в моем коде.

Спасибо, Нгуен

1 Ответ

0 голосов
/ 05 ноября 2009

добавить это после auth.token = "-------------------"

auth.UpdateCredentials();

попробуйте это.

...