ASP.NET MVC5 OWIN Facebook authentication suddenly not working

后端 未结 11 2064
孤街浪徒
孤街浪徒 2020-11-27 03:31

Update 2017!

The issue I had when I posted the original question has got nothing to do with the recent changes Facebook made when they forced everyo

11条回答
  •  醉梦人生
    2020-11-27 04:10

    Even though i did everything what sammy34 said, it did not work for me. I was at the same point with HaukurHaf: When i make apirequest manually on browser it works perfect, but if i use my mvc app, GetExternalLoginInfoAsync() always returns null.

    So i changed some rows on sammy34's codes like on this comment: https://stackoverflow.com/a/43148543/7776015

    Replaced:

    if (!request.RequestUri.AbsolutePath.Contains("/oauth"))
    {
    request.RequestUri = new Uri(request.RequestUri.AbsoluteUri.Replace("?access_token", "&access_token"));
    }
    var result = await base.SendAsync(request, cancellationToken);
    if (!request.RequestUri.AbsolutePath.Contains("/oauth"))
    {
    return result;
    }
    

    Instead of:

    var result = await base.SendAsync(request, cancellationToken);
    if (!request.RequestUri.AbsolutePath.Contains("access_token"))
    return result;
    

    And added this row into my FacebookAuthenticationOptions:

    UserInformationEndpoint = "https://graph.facebook.com/v2.8/me?fields=id,name,email,first_name,last_name,picture"
    

    and now it works.(fields and that parameters optional)

    Note: I did not update Microsoft.Owin.Security.Facebook

提交回复
热议问题