I'm trying to create a login with Facebook with Firebase.
My login function is:
public void FacebookLogin()
{
var perms = new List<string>() { "public_profile", "email" };
FB.LogInWithReadPermissions(perms, AuthCallback);
if (FB.IsLoggedIn)
{
string aToken = Facebook.Unity.AccessToken.CurrentAccessToken.UserId;
Firebase.Auth.FirebaseAuth auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
Firebase.Auth.Credential credential = Firebase.Auth.FacebookAuthProvider.GetCredential(aToken);
auth.SignInWithCredentialAsync(credential).ContinueWith(task => {
if (task.IsCanceled)
{
Debug.LogError("SignInWithCredentialAsync was canceled.");
return;
}
if (task.IsFaulted)
{
Debug.LogError("SignInWithCredentialAsync encountered an error: " + task.Exception);
return;
}
Firebase.Auth.FirebaseUser newUser = task.Result;
Debug.LogFormat("User signed in successfully: {0} ({1})",
newUser.DisplayName, newUser.UserId);
});
}
}
My problem is the warning "Database URL not set in the Firebase config.", followed by a SignInWithCredentialAsync error (System.AggregateException).
How can I change the URL in Firebase config? Where is this Firebase config located?
I'm a newbie in coding, thanks for the support.
I should manage to link all the Id app, Oauth etc correctly( i hope so), I believe the problem is caused by the empty URL for firebase db.
firebaser here
There is a bug in the Firebase games SDKs at the moment, which makes it require that a databaseURL value is specified in the google-services.json and/or google-services-info.plist files. Unfortunately that key is not present anymore, unless you actually use the Realtime Database.
The easiest might be to:
Create a Realtime Database instance in the Firebase console.
Download the updated configuration files and add them to your project again.
Update: I just spotted that the issue on Github also mentions a workaround for the problem.
Related
I have setup firebase config for flutter
According to documentation https://pub.dev/packages/firebase_remote_config#-readme-tab-
My key is
then I have Published also then i tried following code and it will return
'Unable to fetch remote config. Cached or default values will be ''used'
could you please point issue
I have tried those also
Firebase Remote Config - Initial fetch return local default values
Remote config in Flutter app throws exception on fetch
try {
remoteConfig.getString('welcome')[![enter image description here][1]][1]
// Using default duration to force fetching from remote server.
await remoteConfig.fetch(expiration: const Duration(seconds: 0));
await remoteConfig.activateFetched();
} on FetchThrottledException catch (exception) {
// Fetch throttled.
print(exception);
} catch (exception) {
print(
'Unable to fetch remote config. Cached or default values will be '
'used');
}
This worked fine for me,
await remoteConfig.ensureInitialized();
it's work for me
FirebaseRemoteConfig remoteConfig = FirebaseRemoteConfig.instance;
initializeRemote() async {
// remoteConfig = await setupRemoteConfig();
//!- must be active firebase remote config
bool updated = await remoteConfig.fetchAndActivate();
if (updated) {
print("found");
// the config has been updated, new parameter values are available.
} else {
print("not print");
// the config values were previously updated.
}
await remoteConfig.ensureInitialized().then((value) async {
print("remote value -> ${await remoteConfig.getString("app_version")}");
});
}
Usually when you fight these problems, in the end, everything gets mixed up. I think after the post you could already see the configured value, but the error occurs when querying another parameter name. Add the following line to see the actual error you are getting.
print('EXCEPTION: $exception');
try {
await remoteConfig.fetch(expiration: const Duration(seconds: 0));
await remoteConfig.activateFetched();
String forceUpdateCurrentVersion =
remoteConfig.getString('force_update_current_version');
double newVersion =
double.parse(forceUpdateCurrentVersion.trim().replaceAll(".", ""));
if (newVersion > currentVersion) {
_showVersionDialog(context);
}
} on FetchThrottledException catch (exception) {
// Fetch throttled.
print(exception);
} catch (exception) {
print('EXCEPTION: $exception');
print('Unable to fetch remote config. Cached or default values will be '
'used');
}
Just put value don't put braces for Default value
For Example
Then use below code in flutter
remoteConfig.getString('IT_');
If you are using Android emulator, ensure it has Google play services enabled.
I have to integrate firebase remote config to my flutter app. From the searches in various sites, I couldn't find the complete solution.
class RemoteConfigurartion{
Future<RemoteConfig> setupRemoteConfig() async {
String value =null;
final RemoteConfig remoteConfig = await RemoteConfig.instance;
remoteConfig.setConfigSettings(RemoteConfigSettings(debugMode: false));
remoteConfig.setDefaults(<String, dynamic>{
'riddle': "off",
});
try {
// Using default duration to force fetching from remote server.
await remoteConfig.fetch(expiration: const Duration(seconds: 0));
await remoteConfig.activateFetched();
} on FetchThrottledException catch (exception) {
// Fetch throttled.
print(exception);
} catch (exception) {
print(
'Unable to fetch remote config. Cached or default values will be '
'used');
}
return remoteConfig;
}
}
This is what I found already. This the result I'm getting:
No implementation found for method RemoteConfig#instance on channel plugins.flutter.io/firebase_remote_config
But I have added all the plugins in the pubspec.yaml and in android gradle folder
Can anyone help me to find out a complete solution to integrate remote config to a flutter app?
Make sure that firebase_core is initialized, and for Android, google-services.json should be in the app folder. Aside from that, there doesn't seem to be any issues on your code. You might've missed some steps during set up.
If you've just added the plugins, it's best to run the app using restart instead of hot reload to ensure that all recently added plugins is included in the build.
im using this tutorial:
https://firebase.google.com/docs/auth/admin/create-custom-tokens#using_a_service_account_id
to create a node.js function (deployed to google cloud functions) to authenticate my users. the function is super simple:
const admin = require('firebase-admin');
admin.initializeApp({
serviceAccountId: 'authenticator#igibo-b0b27.iam.gserviceaccount.com'
});
exports.authenticate = (req, res) => {
let pass;
let uid;
if (req.query) {
if (req.query.v == 3) {
pass = req.query.p;
uid = req.query.u;
}
admin.auth().createCustomToken(uid)
.then(function(customToken) {
res.status(200).send(customToken);
return customToken;
})
.catch(function(error) {
console.error("Error creating custom token:" + JSON.stringify(error));
res.status(400).send(error);
});
} else {
console.error("EMPTY to authentication");
res.end();
}
};
but im getting this annoying error:
{"code":"auth/insufficient-permission","message":"Permission iam.serviceAccounts.signBlob is required to perform this operation on service account projects/-/serviceAccounts/authenticator#igibo-b0b27.iam.gserviceaccount.com.; Please refer to https://firebase.google.com/docs/auth/admin/create-custom-tokens for more details on how to use and troubleshoot this feature."}
in the very same tutorial it says i must go to IAM and adjust some roles for the service account WHICH I DID but still getting this error.
this is a absolutelly simple task and shouldn't being such a hassle...
what i am forgetting? the id is correct! the role is correct! the code is correct!
what is wrong?
Firebase mentions about this error on its docs:
https://firebase.google.com/docs/auth/admin/create-custom-tokens#failed_to_determine_service_account
You must initialize your app correctly through a JSON config file.
A simple fix would be:
Go to
https://console.cloud.google.com/iam-admin/iam?project=PROJECT_NAME
Edit your default service account.
Add the role Service Account
Token Creator
In a few minutes your project will be able to create signed tokens.
I am working on an Ionic 3 application where i have used google firebase for login. So, i needed to verify the firebase token in my back-end. I have used FirebaseAdmin(Version 1.2.0) plugin for verifying the token.
try
{
var firebaseAppInstance = FirebaseApp.GetInstance(firebaseAppName);
if (firebaseAppInstance == null)
{
firebaseAppInstance = FirebaseApp.Create(new AppOptions()
{
Credential = GoogleCredential.FromFile("firebase-servicekey.json")
}, firebaseAppName);
}
var decodedToken = await FirebaseAuth.GetAuth(firebaseAppInstance).VerifyIdTokenAsync(firebaseToken);
if (userId == decodedToken.Uid)
{
return true;
}
}
catch (Exception e)
{
return false;
}
But, sometimes i am getting Firebase ID token issued at future timestamp error. And sometimes, i could verify the same firebase token without this error.
Can anyone point me out what's the problem here? Thanks in advance.
The issue has been resolved here. Just need to update the new release of that package. Here is the release notes
I have created an Ionic app which uses Firebase Authentication. I'm trying to authenticate using Google. This is a part of my code trying to achieve the same.
$cordovaOauth.google("//removed_client_id", ["https://www.googleapis.com/auth/userinfo.profile"]).then(function (result) {
var credentials = firebase.auth.GoogleAuthProvider.credential(result.id_token);
console.log(JSON.stringify(result));
console.log(JSON.stringify(credentials));
firebase.auth().signInWithCredential(credentials).then(function (authData) {
console.log(JSON.stringify(authData));
}
}
The problem is I'm not getting any results in 'authData' as fields like displayName, photoUrl, email are null. What am I doing wrong?