Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

How do you find or create the 'credential'? #314

Closed
aloenobilis opened this issue May 3, 2020 · 9 comments
Closed

How do you find or create the 'credential'? #314

aloenobilis opened this issue May 3, 2020 · 9 comments

Comments

@aloenobilis
Copy link

aloenobilis commented May 3, 2020

Hi,

Firebase allows for service account credentials to be created, which downloads a .json with a private key, client id, client mail etc, but I dont see a single string token/credential.
The api provided by firebase-dart is dissimilar from nodejs.

final fbClient = FirebaseClient(credential);

How do you find or create the 'credential'?

EDIT: this is for the Dart VM

EDIT: should import "package:googleapis_auth/auth_io.dart"; be used?

@aloenobilis
Copy link
Author

@kevmoo can you maybe help with this?

@andrerpena
Copy link

@sashvoncurtis I am also on a quest to get this working. I even mentioned this issue on this Stackoverflow question I posted now https://stackoverflow.com/questions/61835023/how-do-i-access-firebase-firecloud-from-dart-vm-dart-integration-tests

@aloenobilis
Copy link
Author

@Ehesp help us! :)

@Ehesp
Copy link

Ehesp commented May 21, 2020

Hey, not directly involved here but it does look as through you need to pass in an auth token; it's left open as that can come from anywhere (see https://firebase.google.com/docs/database/rest/auth).

To keep it all in Dart land, you'd want to use https://pub.dev/packages/googleapis along with the auth dep: https://pub.dev/documentation/googleapis_auth/latest/

@aloenobilis
Copy link
Author

@Ehesp will give that a try, thanks.

@aloenobilis
Copy link
Author

@Ehesp https://pub.dev/packages/googleapis is where its at. Thanks again.

@andrerpena
Copy link

andrerpena commented May 27, 2020

@sashvoncurtis , before you close, did you get to make this to work?

I dont know how to transform the credentials from googleapis into the string that FirebaseClient expects. This is the question I ask here:

https://stackoverflow.com/questions/61835023/how-do-i-access-firebase-firestore-from-dart-vm-dart-integration-tests

If you found the answer, it would be amazing if you could share it.

Thank you

@aloenobilis
Copy link
Author

@andrerpena no worries.

The googleapis package is the one you want to use, it provides a FirestoreApi object, docs: https://pub.dev/documentation/googleapis/latest/googleapis.firestore.v1/googleapis.firestore.v1-library.html.

You need to specify the import for firestore, import 'package:googleapis/firestore/v1.dart';,
the service credentials are passed to clientViaServiceAccount which returns an authenticated http-client which is used to make the requests.

Make sure to install both googleapis and googleapis_auth.

Hope that helps.

@andrerpena
Copy link

Thank you @sashvoncurtis ! That worked

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants