Client-side tokens? #180
-
Is there a way to generate signed requests/sessions to Deepgram? I'm using the streaming transcription endpoint via a bounce to our servers which adds N ms of latency and requires me to maintain sessions that I'd prefer not to. Can I:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 12 replies
-
Yes. API keys can be set to expire. If you create one in the console.deepgram.com UI, you'll see an option to set an expiration. In this screenshot, it's set to 15 minutes: Similarly, if you're creating an api key using the API, you can either set an |
Beta Was this translation helpful? Give feedback.
-
Currently, officially, we do not have a solution for client-side tokens. Our recommendation is to use a proxy service of your own, to mask the API key in requests you make to our API. This should essentially act as a middleman to add the token to the request, and forward on the replies to the client. You can then define your own Auth between the proxy and your client, to prevent unauthenticated users from making API calls - or not, that is up to you. While we have the option (as Chris points out) of short-lived tokens, our recommendation will always be to never expose an API key in the client. |
Beta Was this translation helpful? Give feedback.
-
So, that's what we ended up doing but as @coreyward said, it requires a completely different infrastructure from what's needed for other use cases, we have to deal with both the incoming and outgoing connections having potential networking issues, and we have to "reverse-engineer" the protocol to replace our own app API keys with the deepgram API key in our proxy. This adds costs, latency, and complexity. As was suggested before, what I would greatly prefer is if we were able to sign short-lived tokens that could be used by the end-user to connect directly to Deepgram. Something like:
Another option is to provide a NuGet (for C# at least) that you maintain that provides the mechanism to do the forwarding and authentication of connections, to avoid having all customers re-implement the logic. I understand the complexity for Deepgram, however I was surprised since I'd expect any service offering STT using Deepgram to require the exact same thing. Any feedback on this would be greatly welcome! |
Beta Was this translation helpful? Give feedback.
Currently, officially, we do not have a solution for client-side tokens.
Our recommendation is to use a proxy service of your own, to mask the API key in requests you make to our API. This should essentially act as a middleman to add the token to the request, and forward on the replies to the client. You can then define your own Auth between the proxy and your client, to prevent unauthenticated users from making API calls - or not, that is up to you.
While we have the option (as Chris points out) of short-lived tokens, our recommendation will always be to never expose an API key in the client.