fcm-rust icon indicating copy to clipboard operation
fcm-rust copied to clipboard

Support for multi-tenancy

Open chris13524 opened this issue 1 year ago • 4 comments

This client depends on the filesystem and a specific dotenv configuration in order to configure the FCM client. My use case, however, requires working with a number of FCM credentials sourced from a database.

I think this depends on https://github.com/makarski/gauth-rs/issues/28

I'm willing to contribute this support myself :)

chris13524 avatar Apr 09 '24 23:04 chris13524

Very useful to have this more flexible indeed!

We could extract the credentials part from fcm::client::Client and create a Credentials struct for this, which is then used by Client. This new struct allows a filename or string for the config and calls ServiceAccount::from_string or similar for your usecase.

rj76 avatar Apr 10 '24 08:04 rj76

I was thinking very similar! We keep new() that defaults to ServiceAccount::from_file but then have a second method from_credentials() which accepts a string

This would also read the credentials file once on startup rather than twice for every message which is an important step for proper re-use of the Service Account access token.

chris13524 avatar Apr 10 '24 12:04 chris13524

Is support for hotswpping credential files on-disk an intentional feature? I'm thinking of removing this ability in my refactor as it would be simpler

chris13524 avatar Apr 17 '24 20:04 chris13524

I haven't given that much thought yet, no.

rj76 avatar Apr 18 '24 08:04 rj76