Comments (9)
Can you try the latest version of the package (v2.0.1)? In case of an error it throws a FirebaseAuthException which should contain all information you should need to debug it (target url, post data and most imporantly responseData, which should contain the reason for the error).
from firebase-authentication-dotnet.
Thank you for the update.
I get "invalid key" as reason
in exception.
Here is what I have, don't know where I am going wrong.
Privacy of keys does not matter. It's all for testing purposes.
The first option gets the idtoken from Auth0 and creates the fireabse token with firebaseAuthentication
The second option generates the firebase auth token from Auth0 .
//KEYS AND IDs
const string FirebaseApiKey = "463216751920-ng92hpkvcq6j9jjud8m3ov0tmfov6ou6.apps.googleusercontent.com";
const string FirebaseBaseURL = "https://simplesocialmedia-7a3a2.firebaseio.com/";
const string FirebaseClientId = "463216751920-npspguchren5atatb2f1le7ec0uooqb0.apps.googleusercontent.com";
const string FirebaseSecret = "iAnU0wTbyLU2ZpWSU1IpeDjj";
const string Auth0ClientId = "VWjSXo9F4xPLlAm2KMyrLoK8mWwshXb4";
const string Auth0Domain = "simplesocialmedia.auth0.com";
private async void Auth0Login()
{
var firebase = new FirebaseClient(FirebaseBaseURL);
var auth0 = new Auth0Client(Auth0Domain, Auth0ClientId);
MessageDialog _ms;
var user = await auth0.LoginAsync();
/*
Auth0AccessToken : "mxSKgCo6SbC87CUR"
IdToken: ""eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL3NpbXBsZXNvY2lhbG1lZGlhLmF1dGgwLmNvbS8iLCJzdWIiOiJmYWNlYm9va3wxMzkyNTM5Nzk3NDQyODcwIiwiYXVkIjoiVldqU1hvOUY0eFBMbEFtMktNeXJMb0s4bVd3c2hYYjQiLCJleHAiOjE0NzMxMjMzMTgsImlhdCI6MTQ3MzA4NzMxOH0.wxgoxq1haDtjhS0nJlxN_Rc78fl_C6Ow0jrcxpKThy4"
Profile: part of it below
RefreshToken: ""
*/
var idToken = user.IdToken; //token for external APIs
var auth0Token = user.Auth0AccessToken; //token for auth0 APIs
var profile = user.Profile;
/*
{
"context":{
"identities": [{ "provider": "facebook", "user_id": "1392539797442870", "connection": "facebook", "isSocial": true } ]
}
*/
var connection = profile["context"]["identities"]["connection"].ToString();
///////////////////////////////////////////////////////////////////////////////////////////
//gerneate firebase auth token with Firebase.Auth
var provider = new FirebaseAuthProvider(new FirebaseConfig(FirebaseApiKey));
FirebaseAuthType authType;
if (connection == "facebook")
authType = FirebaseAuthType.Facebook;
else if (connection == "google")
authType = FirebaseAuthType.Google;
else
return;
try
{
var auth = await provider.SignInWithOAuthAsync(authType, idToken);
var result = await firebase.Child("users").WithAuth(auth.FirebaseToken).PostAsync(new MyUser { FirstName = "A", LastName = "B" });
_ms = new MessageDialog(result.Key + "\n");
await _ms.ShowAsync();
}
catch
{
//Exception: FirebaseAuthException
//reason: Invalid key
//From SignInWithOAuthAsync(...)
_ms = new MessageDialog("error step 1");
await _ms.ShowAsync();
}
///////////////////////////////////////////////////////////////////////////////////////////
//generate firebase auth token from Auth0
var token = await auth0.GetDelegationToken("firebase", idToken, user.RefreshToken, Auth0ClientId);
/*
{
{
"token_type": "Bearer",
"expires_in": 36000,
"id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL3NpbXBsZXNvY2lhbG1lZGlhLmF1dGgwLmNvbS8iLCJzdWIiOiJmYWNlYm9va3wxMzkyNTM5Nzk3NDQyODcwIiwiYXVkIjoiVldqU1hvOUY0eFBMbEFtMktNeXJMb0s4bVd3c2hYYjQiLCJleHAiOjE0NzMxMjQ1ODIsImlhdCI6MTQ3MzA4ODU4MiwidiI6MCwiZCI6eyJmYl9pZCI6ImZhY2Vib29rfDEzOTI1Mzk3OTc0NDI4NzAifSwiYXpwIjoiVldqU1hvOUY0eFBMbEFtMktNeXJMb0s4bVd3c2hYYjQifQ.Nf2A6TVFzsIsZCZ7-ejiwdeU54oKQZ-gi-tB2FR1xns"
}
}
*/
var firebaseToken = token["id_token"].ToString();
try
{
var _result = await firebase.Child("users").WithAuth(firebaseToken).PostAsync(new MyUser { FirstName = "A", LastName = "B" }); //exception here.
_ms = new MessageDialog(_result.Key + "\n"); //show result
await _ms.ShowAsync();
}
catch
{
//HTTP exception: Response status code does not indicate success: 400
//From: firebase.Child(..).WidthAuth(...)
_ms = new MessageDialog("error step 2");
await _ms.ShowAsync();
}
}
//////////////////////////////////////////////////////////////////////////////////////////
public class MyUser
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
I've also tried generating the access token using winfbsdk
(which worked well) before passing in SignInWidthOAuthAsync()
. Getting the same results.
I've checked all loose ends. Don't know what is causing this. Maybe I'm not using the tokens or keys correctly.
from firebase-authentication-dotnet.
I never worked with Auth0 so I'm not sure what kind of tokens it generates. Check out the samples (I just pushed them), they may help.
from firebase-authentication-dotnet.
I have similar problem.
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "keyInvalid",
"message": "Bad Request"
}
],
"code": 400,
"message": "Bad Request"
}
}
var firebase = new FirebaseClient("https://myapp.firebaseio.com/"); var authProvider = new FirebaseAuthProvider(new FirebaseConfig("myFirebaseScerectMechmFmi6")); FirebaseAuthLink authEmail = await authProvider.CreateUserWithEmailAndPasswordAsync(username, password);
from firebase-authentication-dotnet.
I think the problem is with the Legacy Firebase App, I created another one and it does works for me.
@bezysoftware can you confirm this?
from firebase-authentication-dotnet.
Can I still create "legacy" app in the current Firebase console?
from firebase-authentication-dotnet.
Yes I can still create using my current Firebase legacy account, not sure if you can still create new account. It's on https://www.firebase.com/
from firebase-authentication-dotnet.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from firebase-authentication-dotnet.
Closing the issue due to inactivity. Feel free to re-open
from firebase-authentication-dotnet.
Related Issues (20)
- wpf with dependency injection HOT 1
- (Enchancement) Support Local Storage & Async for IUserRepository HOT 1
- Possibility to check user password HOT 1
- Question: do you not support sign in with custom token? HOT 1
- Email verification HOT 7
- Posibility to change the token expiration HOT 1
- Phone Authentication
- Exception occured during Firebase Http request. HOT 1
- Check if DisplayName already exists HOT 1
- Need Help with login with Google in .NET MAUI HOT 1
- Email Verification Implementation Help HOT 1
- [Endpoints Migration] : identitytoolkit v3 needs to be migrated to something else HOT 1
- Is there a way to get the last time user logged in?
- Create Email and Password issue in .Net MAUI
- [.NET MAUI] How implement "OpenBrowserAndWaitForRedirectToAuthDomain" HOT 2
- I can't get FetchSignInMethodsForEmailAsync to work HOT 2
- How to persist authentication across app restarts ? HOT 6
- Allow FirebaseAuthConfig.RedirectUri to be configurable
- Observed in version 3.7.2 : Parsing error when the password ends (or maybe contains also) a backslash \ HOT 2
- How do you set a photo Url in version 4.1.0?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from firebase-authentication-dotnet.