i faced an error while developing my app, when i used facebook sdk get this error>
Can't Load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and subdomains of your app to the App Domains field in your app settings.
this is my code-->
public sealed partial class MainPage : Page { private const string AppId = "578906892291873"; private const string ExtendedPermissions = "publish_actions, user_managed_groups, user_groups"; public MainPage() { this.InitializeComponent(); }
private async void loginImage_Tapped(object sender, TappedRoutedEventArgs e)
{
var result = await AuthenticateFacebookAsync();
var md = new MessageDialog("your token is: " + result);
await md.ShowAsync();
}
private async Task<string> AuthenticateFacebookAsync()
{
try
{
var fb = new FacebookClient();
var redirectUri =
WebAuthenticationBroker.GetCurrentApplicationCallbackUri().ToString();
var loginUri = fb.GetLoginUrl(new
{
client_id = AppId,
redirect_uri = redirectUri,
scope = ExtendedPermissions,
display = "popup",
response_type = "token"
});
var callbackUri = new Uri(redirectUri, UriKind.Absolute);
var authenticationResult =
await
WebAuthenticationBroker.AuthenticateAsync(
WebAuthenticationOptions.None,
loginUri, callbackUri);
retu ParseAuthenticationResult(fb, authenticationResult);
}
catch (Exception ex)
{
retu ex.Message;
}
}
public string ParseAuthenticationResult(FacebookClient fb,
WebAuthenticationResult result)
{
switch (result.ResponseStatus)
{
case WebAuthenticationStatus.ErrorHttp:
retu "Error";
case WebAuthenticationStatus.Success:
var oAuthResult = fb.ParseOAuthCallbackUrl(new Uri(result.ResponseData));
retu oAuthResult.AccessToken;
case WebAuthenticationStatus.UserCancel:
retu "Operation aborted";
}
retu null;
}
}
