Closed eximius313 closed 1 year ago
Would you mind running dart format on lib/auth/auth_gateway.dart
?
I need to separate the format verification from the unit tests...
Sure, I can do that, but it'll change formatting in the whole file - even in your code and this goes against This also goes for formatting code outside of that affected by your contribution
.
Maybe I fill second PR with formatting and finals?
By the way - maybe instead of This also goes for formatting code outside of that affected by your contribution
there should be something like "every file must go through dart format
"?
Sure, I can do that, but it'll change formatting in the whole file - even in your code and this goes against
This also goes for formatting code outside of that affected by your contribution
.
That's fine. It actually shouldn't change much outside of the already touched lines since the code was (supposed to) already be correctly formatted.
By the way - maybe instead of
This also goes for formatting code outside of that affected by your contribution
there should be something like "every file must go throughdart format
"?
Good idea, I'll update the text.
done
Damn 80 character lines length... fixed now
There seems to be an analysis error:
error - test/firebase_auth_test.dart:26:38 - Undefined name 'customToken'. Try correcting the name to one that is defined, or defining the name. - undefined_identifier
umm... I'm confused:
PS C:\workspaces\firedart> dart analyze --fatal-infos
Analyzing firedart...
No issues found!
Actually this is on me. The credentials are loaded from the project secrets by the CI. I need to create a test token and add it there, give me a couple of minutes...
If it helps - here is full Java code to create it:
package firebase.admin.test;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.FirebaseDatabase;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.IOException;
import java.util.Map;
import java.util.HashMap;
public class App {
public static void main(String[] args) throws Exception {
InputStream serviceAccount = App.class.getClassLoader().getResourceAsStream("serviceAccountKey.json");
FirebaseOptions options = new FirebaseOptions.Builder()
.setCredentials(GoogleCredentials.fromStream(serviceAccount))
.setDatabaseUrl("https://<URL>")
.build();
FirebaseApp.initializeApp(options);
final String UID = "some-test-uid";
final String customToken = FirebaseAuth.getInstance().createCustomTokenAsync(UID).get();
System.out.println(customToken);
}
}
and a build.gradle
file:
plugins {
id 'application'
}
repositories {
mavenCentral()
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2'
implementation 'com.google.guava:guava:31.0.1-jre'
implementation 'com.google.firebase:firebase-admin:9.1.1'
}
application {
mainClass = 'firebase.admin.test.App'
}
tasks.named('test') {
useJUnitPlatform()
}
I had assumed custom tokens were permanent, but it seems they're only valid for 1h, so we'll have to create one for testing.
We already have a test service-account.json
so in theory we should be able to generate a test token on demand - it would actually be a nice improvement to Firedart.
Do you want to take that on in this PR as well? If not, then I'll create a token locally and test it on my machine to merge your contribution and open a new issue for the token generation.
Let's make separate PR
Released on pub.dev
Thank you!
@cachapa I've just added this PR with finals we talked about in your review: https://github.com/cachapa/firedart/pull/115
Merged, thanks!
This PR adds support for signInWithCustomToken authentication and fixes https://github.com/cachapa/firedart/issues/98