Example #1
0
        public void CallAuthenticatedWebService()
        {
            // Retrieve this user's authentication object we've stored in the session state
            Yahoo.Authentication auth = Session["Auth"] as Yahoo.Authentication;

            if (auth != null)
            {
                // Call web service and output result into a DIV tag
                Div1.InnerHtml = auth.GetAuthenticatedServiceString(
                    new System.Uri("http://photos.yahooapis.com/V1.0/listServices"));
            }
        }
        private void Page_Load(object sender, System.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");
            }
        }