雅虎BBAuthen与身份验证会话?

时间:2009-09-10 03:02:14

标签: yahoo

我正在尝试将yahoo BBA与我的网络应用程序一起使用,但我总是因雅虎身份验证问题而失败。

这是我奇怪的代码:

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());
}

终点网址: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 :(得分:0)

在auth.token =“-------------------”

之后添加
auth.UpdateCredentials();

试试这个。