2014-11-28 3 views
1

내가 트위터 라이브러리에 oauthusing의 LINQ에서 지금이 오류를 직면하고있다 : 나는 https://linqtotwitter.codeplex.com/wikipage?title=Implementing%20OAuth%20for%20ASP.NET%20Web%20Forms&referringTitle=Learning%20to%20use%20OAuth 는 OAuth를 프로세스를 구현하기 :필수 oauth_verifier 매개 변수를 제공하지 asp.net의 C#을

<?xml version="1.0" encoding="UTF-8"?> 
<hash> 
<error>Required oauth_verifier parameter not provided</error> 
<request>/oauth/access_token</request> 
</hash> 

나는이 문서 링크를 따랐다 다음 줄에이 오류가 표시됩니다. await auth.CompleteAuthorizeAsync (new Uri (twitterCallbackUrl));

아래의 전체 코드입니다,이 날 도와주세요 : 사용자 정의 URL 응용 프로그램이 승인을 요청 후 트위터 반환 매개 변수를 포함하지 않기 때문에

AspNetAuthorizer auth; 
    string twitterCallbackUrl = "http://127.0.0.1:58192/Default.aspx"; 

    protected async void Page_Load(object sender, EventArgs e) 
    { 
     auth = new AspNetAuthorizer 
     { 
      CredentialStore = new SessionStateCredentialStore 
      { 
       ConsumerKey = ConfigurationManager.AppSettings["consumerKey"], 
       ConsumerSecret = ConfigurationManager.AppSettings["consumerSecret"] 
      }, 
      GoToTwitterAuthorization = 
       twitterUrl => Response.Redirect(twitterUrl, false) 
     }; 

     if (!Page.IsPostBack && Request.QueryString["oauth_token"] != null) 
     { 
      __await auth.CompleteAuthorizeAsync(new Uri(twitterCallbackUrl));__ 

      // This is how you access credentials after authorization. 
      // The oauthToken and oauthTokenSecret do not expire. 
      // You can use the userID to associate the credentials with the user. 
      // You can save credentials any way you want - database, isolated 
      // storage, etc. - it's up to you. 
      // You can retrieve and load all 4 credentials on subsequent queries 
      // to avoid the need to re-authorize. 
      // When you've loaded all 4 credentials, LINQ to Twitter will let you 
      // make queries without re-authorizing. 
      // 
      var credentials = auth.CredentialStore; 
      string oauthToken = credentials.OAuthToken; 
      string oauthTokenSecret = credentials.OAuthTokenSecret; 
      string screenName = credentials.ScreenName; 
      ulong userID = credentials.UserID; 

      //Response.Redirect("~/Default.aspx", false); 
     } 
    } 

    protected async void AuthorizeButton_Click(object sender, EventArgs e) 
    { 
     await auth.BeginAuthorizeAsync(new Uri(twitterCallbackUrl)); 
     //await auth.BeginAuthorizeAsync(Request.Url); 
    } 

답변

2

문제가 발생합니다. CompleteAuthorizationAsync에 중단 점을 설정하고 직접 실행 창에 Request.Url을 입력하면 다음 매개 변수가 표시됩니다.

여전히 수동으로 URL을 지정하려면 이러한 매개 변수를 포함시켜야합니다. 당신은 두 개의 매개 변수가 @Joe 완전히 옳다

await auth.CompleteAuthorizeAsync(Request.Url); 
+0

: 그 이미 적절한 매개 변수를 포함하기 때문에 또는

string completeOAuthUrl = twitterCallbackUrl + Request.Url.Query; await auth.CompleteAuthorizeAsync(completeOAuthUrl); 

, 당신은 단지 페이지 URL을 사용할 수 있습니다 여기에 한 가지 방법이다 : oauth_token = xxxxxxx 및 oauth_verifier = xyxyxyxy, 고맙습니다. 나를 도와 주신 많은 분 :) SessionStateCredentialStore 대신 –

+0

대신 Inproc 세션 모드에서 credentilas를 저장하려고합니다. InMemoryCredentialStore를 시도하면 오류가 발생하기 시작합니다. 거기에 대한 모든 문서가 있다면 그렇다면 나에게 그것을 참조하십시오? –

+1

@SanjayBathre SessionStateCredentialStore는 자연스럽게 때로는 재활용되는 ASP.NET 세션 상태에 따라 다릅니다. InProc을 사용하는 경우 자격 증명이 느슨합니다. State Server 또는 SQL Server를 사용하도록 재구성하는 것이 가장 좋습니다. 다음은 ASP.NET 세션 상태의 작동 방식을 설명하는 문서입니다. http://msdn.microsoft.com/en-us/library/ms972429.aspx. –