0

Annoyingly I have been trying to solve this issue for many hours, every answer is no direct solution:

{
   "error": {
      "message": "Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request",
      "type": "OAuthException",
      "code": 100
   }
}

I have been banging my head against the wall!. I am using the facebook soap client for this http://pastebin.com/G7ysgbdX

This will allow us to integrate (with the user's permission) their timeline. Facebook is saying the URL's do not match. How do I test this?

This works locally but not on the server with the exact same code except http://free-rsvp.com/ instead of localhost:53111/

This is the below URL. I cannot see anything wrong!

Any advice would be appreciated.

provider_%3dFacebookPro%26_sid_%3da80359b555c54b8f8d2f4f8e803f9125&client_secret=212360b3ea6478fd0a0491e736b54256&code=AQCyTDStiB5gsQpKMx4uI1yFesVnLnWfE3u70VsB02-4HSyUCTbcf_3oHMo7QQI2as_pw1tpFONs8tClq4FxCr4AzuCMzLBsRnyOM3dcattTATdU-ahq5cjr4lPJNp2gkTrpgWUmqDEVQ8PBvYFB1LdWJpojxRIC24lv0GkQSSqdrct41UGHfDjhnPfI1mV945NgVJSfebhJP7O0GWxP9o9g_4svDCKa2LtCRbo7nDfWLeiE9fGULhmuJDjefAFZ5VMiYj8SrA4QtZXIu8jUQSQT89VYEP8PuG2hS_wMr0TL_GmcvEhNzQ8psPpPWFYhmSo">https://graph.facebook.com/oauth/access_token?client_id=523007704381837&redirect_uri=http%3a%2f%2ffree-rsvp.com%3a80%2fAccount%2fExternalLoginCallback%3fReturnUrl%3d%252FDashboard%26_provider_%3dFacebookPro%26_sid_%3da80359b555c54b8f8d2f4f8e803f9125&client_secret=212360b3ea6478fd0a0491e736b54256&code=AQCyTDStiB5gsQpKMx4uI1yFesVnLnWfE3u70VsB02-4HSyUCTbcf_3oHMo7QQI2as_pw1tpFONs8tClq4FxCr4AzuCMzLBsRnyOM3dcattTATdU-ahq5cjr4lPJNp2gkTrpgWUmqDEVQ8PBvYFB1LdWJpojxRIC24lv0GkQSSqdrct41UGHfDjhnPfI1mV945NgVJSfebhJP7O0GWxP9o9g_4svDCKa2LtCRbo7nDfWLeiE9fGULhmuJDjefAFZ5VMiYj8SrA4QtZXIu8jUQSQT89VYEP8PuG2hS_wMr0TL_GmcvEhNzQ8psPpPWFYhmSo

EDIT The url that takes me to facebook is:

provider_%253DFacebookPro%2526_sid_%253Dbfe82f104ab34d1aa0f44c477c4d7819%26scope%3Demail%252Cuser_likes%252Cfriends_likes%252Cuser_birthday%252Cpublish_checkins%252Cpublish_stream%26client_id%3D523007704381837%26ret%3Dlogin&cancel_uri=http%3A%2F%2Ffree-rsvp.com%2FAccount%2FExternalLoginCallback%3FReturnUrl%3D%252FDashboard%26_provider_%3DFacebookPro%26_sid_%3Dbfe82f104ab34d1aa0f44c477c4d7819%26error%3Daccess_denied%26error_code%3D200%26error_description%3DPermissions%2Berror%26error_reason%3Duser_denied%23_%3D_&display=page">https://www.facebook.com/login.php?skip_api_login=1&api_key=523007704381837&signed_next=1&next=https%3A%2F%2Fwww.facebook.com%2Fdialog%2Foauth%3Fredirect_uri%3Dhttp%253A%252F%252Ffree-rsvp.com%252FAccount%252FExternalLoginCallback%253FReturnUrl%253D%252FDashboard%2526_provider_%253DFacebookPro%2526_sid_%253Dbfe82f104ab34d1aa0f44c477c4d7819%26scope%3Demail%252Cuser_likes%252Cfriends_likes%252Cuser_birthday%252Cpublish_checkins%252Cpublish_stream%26client_id%3D523007704381837%26ret%3Dlogin&cancel_uri=http%3A%2F%2Ffree-rsvp.com%2FAccount%2FExternalLoginCallback%3FReturnUrl%3D%252FDashboard%26_provider_%3DFacebookPro%26_sid_%3Dbfe82f104ab34d1aa0f44c477c4d7819%26error%3Daccess_denied%26error_code%3D200%26error_description%3DPermissions%2Berror%26error_reason%3Duser_denied%23_%3D_&display=page

4

1 回答 1

0

这是我的一段服务器端身份验证代码(MVC4 项目)。您应该查看的部分是如何生成重定向 URL - 同样 - 在“Authorize”和“AuthorizeCallback”函数中 - 并传递给 facebook 客户端:

[HttpPost]
public ActionResult Authorize(Guid eventId)
{
    var @event = this.eventRepository.Find(eventId);

    var redirectUri = ConfigurationProvider.HostingEndpoint + this.Url.Action("AuthorizeCallback", new { eventCode = @event.Code });

    var service = new FacebookClient();
    var loginUrl = service.GetLoginUrl(new {
        client_id = ConfigurationProvider.FacebookAppId,
        client_secret = ConfigurationProvider.FacebookAppSecret,
        redirect_uri = redirectUri,
        response_type = "code",
        scope = "manage_pages, publish_actions, user_photos, publish_stream" // Add other permissions as needed
    });

    return new RedirectResult(loginUrl.AbsoluteUri, permanent: false);
}

public ActionResult AuthorizeCallback(string code, string eventCode, UserProfile userProfile)
{
    var @event = this.eventRepository.Find(eventCode);

    if (string.IsNullOrWhiteSpace(code) == true)
    {
        // means user clicked "cancel" when he was prompted to authorize the app
        // todo: show some error message? or just redirect back?
        return this.RedirectToAction("Event", "Dashboard", new { eventCode = @event.Code, feature = FeatureType.Update });
    }

    var redirectUri = ConfigurationProvider.HostingEndpoint + this.Url.Action("AuthorizeCallback", new { eventCode = @event.Code });

    var fb = new FacebookClient();
    dynamic result = fb.Post("oauth/access_token", new
    {
        client_id = ConfigurationProvider.FacebookAppId,
        client_secret = ConfigurationProvider.FacebookAppSecret,
        redirect_uri = redirectUri,
        code = code
    });

    var accessToken = result.access_token;

    // update the facebook client with the access token so 
    // we can make requests on behalf of the user
    fb.AccessToken = accessToken;

    // Get the user's information
    dynamic me = fb.Get("me");

    return this.RedirectToAction("Event", "Dashboard", new { eventCode = @event.Code, feature = FeatureType.Update });
}
于 2013-11-15T02:49:32.730 回答