я пытаюсь аутентифицировать мое приложение с помощью Facebook и аутентификации через firebase
Я получаю эту ошибку, независимо от того, что я пытаюсь:
Response: {
"error": {
"code": 400,
"message": "I>NVALID_IDP_RESPONSE : Unsuccessful debug_token response from Facebook: {\"error\":{\"message\":\"(#100) The App_id in the input_token did not match the Viewing App\",\"type\":\"OAuthException\",\"code\":100,\"fbtrace_id\":\"AGkb5UAzS66caoh8XplRXpB\"}}",
"errors": [
{
"message": "INVALID_IDP_RESPONSE : Unsuccessful debug_token response from Facebook: {\"error\":{\"message\":\"(#100) The App_id in the input_token did not match the Viewing App\",\"type\":\"OAuthException\",\"code\":100,\"fbtrace_id\":\"AGkb5UAzS66caoh8XplRXpB\"}}",
"domain": "global",
"reason": "invalid"
}
]
}
}
это конфигурация разработчика Facebook:
снимок экрана # 1
снимок экрана # 2
снимок экрана # 3
я также много раз проверял, правильно ли привязаны идентификатор приложения и секрет APP к базе данных
я пытался сбросить секретный код приложения .. не помогло.
весь процесс, чтобы получить accessToken работает хорошо, потому что я могу получить информацию из Facebookprofile
AuthService.cs
using Firebase.Auth;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Threading.Tasks;
namespace mada.Services
{
public class AuthService
{
public FirebaseAuthLink CurrentAuth { get; set; }
public async Task<FirebaseAuthLink> CreateEmailPasswordUser(string email, string password)
{
return await App.FirebaseService.AuthProviderInstance
.CreateUserWithEmailAndPasswordAsync(email, password);
}
public async Task<FirebaseAuthLink> SignInWithEmailPassword(string email, string password)
{
return await App.FirebaseService.AuthProviderInstance
.SignInWithEmailAndPasswordAsync(email, password);
}
public async Task SignInWithFacebook(string accessToken)
{
try
{
var auth = await App.FirebaseService.AuthProviderInstance.SignInWithOAuthAsync(FirebaseAuthType.Facebook, accessToken);
} catch (FirebaseAuthException e)
{
Debug.WriteLine(e.Message);
};
}
public bool IsLoggedIn()
{
return CurrentAuth != null;
}
}
}
FirebaseService.cs
using Firebase.Auth;
using Firebase.Database;
using System;
using System.Collections.Generic;
using System.Text;
namespace mada.Services
{
public class FirebaseService
{
public readonly FirebaseAuthProvider AuthProviderInstance = new FirebaseAuthProvider(new FirebaseConfig("My firebase API key"));
public readonly FirebaseClient FirebaseClientInstance = new FirebaseClient("my firebase url");
}
}
FacebookLogin.cs
using Firebase.Auth;
using mada.Interfaces;
using mada.Models;
using mada.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace mada.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class FaceBookLogin : ContentPage
{
public static string accessToken = null;
string ClientId = "My facebook app ID";
public FaceBookLogin()
{
InitializeComponent();
Indi.IsRunning = true;
var apiRequest =
"https://www.facebook.com/dialog/oauth?client_id="
+ ClientId
+ "&display=popup&response_type=token&redirect_uri=https://www.facebook.com/connect/login_success.html";
var webView = new WebView
{
Source = apiRequest,
HeightRequest = 1
};
webView.Navigated += WebViewOnNavigated;
Content = webView;
}
private async void WebViewOnNavigated(object sender, WebNavigatedEventArgs e)
{
accessToken = ExtractAccessTokenFromUrl(e.Url);
if (accessToken != "")
{
Indi.IsRunning = true;
//var facebookProfile = await FacebookServices.GetFacebookProfileAsync(accessToken);
//App.CurrentAccount = new Accounts { Key = facebookProfile.Id, PhotoUrl = facebookProfile.Picture.Data.Url, NickName = facebookProfile.Name, NewUser = true, UserType = "Facebook" };
//await DBFire.saveAccount(App.CurrentAccount);
await App.AuthService.SignInWithFacebook(accessToken);
Indi.IsRunning = false;
App.Current.MainPage = new MainScrolledPage();
}
else
{
App.Current.MainPage = new LoginPage();
await App.Current.MainPage.DisplayAlert("Didn't accessed to Facebook", "Please Try Again", "OK");
}
}
public async Task GetFacebookProfileAsync(string accessToken)
{
var requestUrl = "https://graph.facebook.com/v2.7/me/"
+ "?fields=name,picture,cover,age_range,devices,email,gender,is_verified"
+ "&access_token=" + accessToken;
Indi.IsRunning = true;
var httpClient = new HttpClient();
var userJson = await httpClient.GetStringAsync(requestUrl);
Indi.IsRunning = false;
}
private string ExtractAccessTokenFromUrl(string url)
{
if (url.Contains("access_token") && url.Contains("&expires_in="))
{
var at = url.Replace("https://www.facebook.com/connect/login_success.html#access_token=", "");
var accessToken = at.Remove(at.IndexOf("&expires_in="));
return accessToken;
}
return string.Empty;
}
}
}