Click here to Skip to main content
15,887,464 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I am using this code to for request token to use Sign in With yahoo using Oenid
this code is showing errorerror "oauth_problem=consumer_key_rejected"

what is wrong with code and what will be the correct code
C#
private void MakeRequestForToken()
   {
       string consumerKey =ConfigurationManager.AppSettings["YahooConsumerKey"];
       string consumerSecret =ConfigurationManager.AppSettings["YahooConsumerSecret"];

       string requestTokenEndpoint = "https://api.login.yahoo.com/oauth/v2/get_request_token";
       string requestTokenCallback = GetRouteableUrlFromRelativeUrl("YahooValidation.aspx/authorizeToken/yahoo/");
       string authorizeTokenUrl = "https://api.login.yahoo.com/oauth/v2/request_auth";

       // Step 1: Make the call to request a token
       var oAuthConsumer = new OAuthConsumerNew();
       var requestToken = oAuthConsumer.GetOAuthRequestToken(requestTokenEndpoint, realm, consumerKey, consumerSecret, requestTokenCallback);
       PersistRequestToken(requestToken);


       // Step 2: Make a the call to authorize the request token
       Response.Redirect(authorizeTokenUrl + "?oauth_token=" + requestToken.Token);
   }



C#
private void HandleAuthorizeTokenResponse()
    {
        string consumerKey =ConfigurationManager.AppSettings["YahooConsumerKey"];
        //string consumerSecret =ConfigurationManager.AppSettings["YahooConsumerSecret"];

        string token = Request.QueryString["oauth_token"];
        string verifier = Request.QueryString["oauth_verifier"];
        string accessTokenEndpoint = "https://api.login.yahoo.com/oauth/v2/request_auth";

        // Exchange the Request Token for an Access Token
        var oAuthConsumer = new OAuthConsumerNew();

        var accessToken = oAuthConsumer.GetOAuthAccessToken(accessTokenEndpoint, realm, consumerKey, consumerSecret, token, verifier, GetRequesttoken().TokenSecret);


        var responseText = oAuthConsumer.GetUserInfo("https://www.yahoo.com/userinfo/email", realm, consumerKey, consumerSecret, accessToken.Token, accessToken.TokenSecret);

        string queryString = responseText;
        NameValueCollection nvc = StringToNameValueCollection(responseText);

        if (nvc["email"] != "")
        {
            string userName = "";
            //string password = "";
            userName = nvc["email"].ToString();
        }
    }



and what will be the string accessTokenEndpoint = "https://api.login.yahoo.com/oauth/v2/request_auth";

Is this accessTokenEndpoint retrive user information like userid,firstname and lastname
or if this will not return this value then what should use to get resired result form yahoo login

Thanks,
Deepak
Posted

1 solution

Yahoo uses OpenId for their login. You use one of the many libraries that are listed on their site.
 
Share this answer
 
Comments
aryan2010 12-Oct-11 7:50am    
I know I got the above code after searching many libraries in Google. But this code is showing problem

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900