使用开放式身份验证的Yahoo Login遇到的问题 [英] Problem tWith Yahoo Login with open authentication

查看:162
本文介绍了使用开放式身份验证的Yahoo Login遇到的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我正在使用此代码来请求令牌以使用Oenid使用雅虎登录
此代码显示错误错误"oauth_problem = consumer_key_rejected"

代码有什么问题,什么是正确的代码

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

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







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




以及字符串accessTokenEndpoint ="https://api.login.yahoo.com/oauth/v2/request_auth";

此accessTokenEndpoint是否检索用户信息,例如userid,firstname和lastname
否则,如果不返回该值,则应使用什么来获得理想的结果表单yahoo login

谢谢,
Deepak




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

推荐答案

Yahoo使用OpenId进行登录.您使用其站点上列出的许多库之一.
Yahoo uses OpenId for their login. You use one of the many libraries that are listed on their site.


这篇关于使用开放式身份验证的Yahoo Login遇到的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆