Reputation: 556
I have a question regarding implementing Google speech, or google cloud API in general, for Android
What I want is to have multiple certificates or API keys for different clients. In practice, I can have 10 different Android devices, linked to Server 1 for Client 1, and 20 different Android devices, linked to another server for Client 2. I would like to split the billing of this clients but using same Android project/package.
In https://github.com/GoogleCloudPlatform/android-docs-samples/tree/master/speech/Speech example there is an OAuth2 Credential used, but the problem here is that you can have only 1 OAuth2 Credential for 1 project, but in this case I would need multiple, so this is not an option.
Even if I implement OAuth2 on a server and refresh Tokens for devices, I would need to have multiples.
In the end I would have 1 google account, with multiple client configuration, where each client is seperate when checking billing info and also for restricting purposes. If I have multiple keys I can just disable one and that is
So my question is (if I can split billing for specific API key/service account, or just know the usage used)
How to change example implementation to use API keys or different Service accounts with GoogleCredentials.fromstream()? Do I need to manually implement API requests to google REST API, or is this possible in Android with something like:
SpeechClient.create(SpeechSettings.newBuilder().setCredentialsProvider {API_KEY}.build())
Upvotes: 0
Views: 470
Reputation: 75970
You can't have billing details per API Keys used on Speech API. Here, the easiest solution is to have one project per customer. When a request come in, check the user Id (because the user is already authenticated and you have a OAuth2 token) on the server and, according with the user info stored somewhere (we use Firestore for user profile storage), call the Speech API in the correct project.
You have 1 billing per project, and a free tier per project also!
Edit 1
It's possible I wasn't clear. Here a schema.
Upvotes: 0