How can I solve the error when accessing facebook login - flutter

I am new in mobile application. I am trying to do facebook login. I followed this Sample application https://pub.dartlang.org/packages/flutter_facebook_connect
but I am getting error in facebook page like this-
"cannot load URl: this domain URL is not included in api domain. to enable this url uploaded, enter all your app domains and subdomains on the api domain field in your app settings".

Use it this way:
_facebookSignIn() async {
final _facebookConnect = new FacebookConnect(
appId: '<APP_ID>',
clientSecret: '<CLIENT_SECRET>');
FacebookOAuthToken token = await _facebookConnect.login();
//FirebaseUser user = await FirebaseAuth.instance.signInWithFacebook(accessToken: token.access);
// return user;}
You have to follow the instructions at developers.facebook, and add http://localhost:8080 in your app Settings under Products>MyApp>Settings

Related

Unable to signinWithCredential() for Ffacebook OAuth with Firebase

I've been unable to successfully use Firebase's signinWithCredentials() for a Facebook login. I've checked and rechecked that i'm using the correct app_id and app_secret on Firebase's authentication page as well as confirmed my settings and added a redirect uri to Facebooks developer console.
I'm using a react-native application built on top of expo. My auth flow is to use expo to display the facebook UI and sign the user in.
const { type, token } = await
Facebook.logInWithReadPermissionsAsync('a_secret_number', {
permissions: ['public_profile', 'email']
});
This successfully returns a token which I then try to integrate with firebase by creating a credential:
const credential = await
firebase.auth.FacebookAuthProvider.credential(token);
the credential looks something like:
{
"accessToken": "EAAIgv4Sw9TQBAA1G30ZC71qyjcRLM4o9kWVxf1oGhZAWAdGVeZBHrSdNADHGxCeZCzyWxZAjEPM1iZCXXdsadsadsaga321432432dsaddsadsadas34214234324asdasdsadsapv1W3ybqtziQC4JRKZA5hD4a50JrVC1rfoFiFZAJZCcoGoRViTQtgevbnNEx8s7ZA1a1Xd6xOQBsnZC1qdJzOTgZDZD",
"providerId": "facebook.com",
}
So, up until now i've confirmed the data is formatted correctly and contains something to send to firebase.
Finally,
try {
await firebase.auth().signInWithCredential(credential);
} catch (error) {
console.log(error);
}
And the error message:
{"error":{"errors":[{"domain":"global","reason":"invalid","message":"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\":\"EpP6p3IVs3a\"}}"}],"code":400,"message":"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\":\"EpP6p3IVs3a\"}}"}}
After Several hours of headbanging and trying to find solutions for this error, i've come to stack overflow for help. Any help or guidance would be appreciated :)
Module Versions:
"expo": "23.0.0",
"firebase": "^4.10.0",
I had the same issue and resolved it by going to firebase console > Authentication > Sign in method (https://console.firebase.google.com/project/your-project-name/authentication/providers), and editing the facebook provider, inserting the correct App id and App secret from the corresponding fb-app found in the facebook developer dashboard (https://developers.facebook.com/apps/your-app-number/).

Facebook login and share not working in Chrome extension because of app domain

I'm new to creating extensions so please bear with me.I'm trying to create an extension that shares the current page URL via Facebook. I followed the instructions Facebook developers site and created a project but i don't know what to put up as the app domain because local host works but chrome-extension://"id" doesn't.
On clicking share button, Error appears"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."
What do I put as the app domain and url?
I had the same problem. This is my solution:
Turn on Embedded Browser OAuth Login in facebook login settings (https://developers.facebook.com/apps/ -> choose your app -> Add product)
Implement manually login flow (https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow). Open oauth url in new tab, listen on changes and than when tab update to success page get from url access token, save token to storage and remove tab.
User facebook graph api (https://developers.facebook.com/docs/graph-api)
Use chrome.identity api to avoid protocol issue. It's looks like:
let options = {
interactive: true,
url: 'https://www.facebook.com/dialog/oauth?' +
stringifyQuery(Object.assign({
app_id: 'your app id here',
redirect_uri: `https://${chrome.runtime.id}.chromiumapp.org/provider_cb`,
response_type: 'token',
access_type: 'online',
}))
};
chrome.identity.launchWebAuthFlow(options, function (redirectUri) {
if (chrome.runtime.lastError) {
callback(new Error((chrome.runtime.lastError as string)));
return;
}
const response = parseUrl(redirectUri);
access_token = response[`#access_token`];
callback(null, access_token);
});

Redirect URI hasn't updated

I have a Meteor app and am using the following function to login with facebook
fbLogin = function() {
Meteor.loginWithFacebook({
requestPermissions: ['public_profile', 'email', 'user_location']
}, function(err) {
if (err)
// redirect to register if popup comes and user isn't on register
Session.set('errorMessage', err.reason || 'Unknown Eror');
console.log(Session.get('errorMessage'));
});
}
The credentials are set and working properly ( app id and secret)
Recently, I updated my Facebook app settings with a new Domain and Site url and yet it does not let me login. It throw the:
Given URL is not allowed by the Application configuration: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.
error with the redirect_uri parameter in the url set to the old site url
Is there possibly a delay on Facebook's end or some other issue at hand?
This can happen when the redirect_uri submitted with the https://www.facebook.com/dialog/oauth request is not present in the list of Valid OAuth redirect URIs under:
Settings >> Advanced >> Security
add a redirect_uri like https://www.facebook.com/connect/login_success.html as an example

Facebook returning error message when using Firebase Login

I am trying to use a Firebase Facebook login in the following way:
Added this to my HTML (to test):
<div
class="fb-like"
data-share="true"
data-width="450"
data-show-faces="true">
</div>
and the firebase script:
<script src="https://cdn.firebase.com/js/client/2.2.5/firebase.js"></script>
This in my module:
var app = angular.module('myApp' ['firebase']);
and then inside my controller:
controller('yokoAppCtrl', function($scope, $firebaseObject, $firebaseAuth, wordsFactory){
var ref = new Firebase("https://resplendent-fire-4284.firebaseio.com/data");
// download the data into a local object
var syncObject = $firebaseObject(ref);
// synchronize the object with a three-way data binding
// click on `index.html` above to see it used in the DOM!
syncObject.$bindTo($scope, "data");
// create an instance of the authentication service
var auth = $firebaseAuth(ref);
// login with Facebook
auth.$authWithOAuthPopup("facebook").then(function(authData) {
console.log("Logged in as:", authData.uid);
}).catch(function(error) {
console.log("Authentication failed:", error);
});
})
When I reload the page in localhost:8000 I get the following message from Facebook:
Given URL is not allowed by the Application configuration: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.
I followed the Firebase docs and this stackoverflow url: Facebook App: Firebase Simple Login URL error but I am still lost.
Under Site URL my app has http://localhost:8000/, I also tried to include under domain name localhost:8000 but Facebook removes it saying "No Top-Level Domains allowed". This is all under "Basic" Settings.
Under "Advanced" I have the following under Valid OAuth redirect URIs:
https://auth.firebase.com/v2/<myFirebase>/auth/facebook/callback
http://localhost:8080/
https://auth.firebase.com/auth/facebook/callback
and I already enabled Facebook connection in Firebase. What am I missing?

Ember Torii facebook authentication not able to get user email

I am using Ember CLI + ember simple auth torii link
to get authentication code from facebook for my ember app.
This is my environment.js file
ENV['torii'] = {
providers: {
'facebook-oauth2': {
apiKey: '865549306850377',
scope: 'email',
//redirectUri: window.document.location.href
redirectUri: 'http://localhost:4200/'
}
}
};
And my login controller looks like this -
facebook: function() {
var _this = this;
this.get('session').authenticate('simple-auth-authenticator:torii', 'facebook-oauth2').then(function(data){
console.log("status - ", _this.get('session'));
});
}
And login.hbs -
<li><button {{action "facebook" "facebook-oauth2"}}>Facebook OAuth2</button></li>
After the user clicks on the link, a facebook popup opens and ember app gets a token.
How do I get the user's email id along with this token ?
Has anybody faced a similar issue ?
So you're using oauth2, so all you're ever going to get is an authorization token. With this token, you can then go off and request other information. The token is basically just there to speed up the validation of users against your application.
If you want to get user information, you would need to create another method (probably on your server-side), which swaps the authorization code for an access token: like so (or alternatively you can request an access token directly, which would remove the need for a server-side solution.
Using the access Token you can then request the Facebook User ID, using the debug token endpoint, and after that you will be able get to any endpoint to get the information you need.