Skip to content

Conversation

thisislvca
Copy link
Contributor

@thisislvca thisislvca commented Jun 25, 2025

Proposed changes

This PR adds proper support for temporary token authentication to the Deepgram Rust SDK. I'm working on a client-side application, and I was surprised to discover that the SDK only supported API key authentication with the "Token" prefix, thus not supporting token-based auth.

  • API Keys: Should use the Token prefix (e.g., Token dg_xxx)
  • Temporary Tokens: Should use the Bearer prefix (e.g., Bearer dg_xxx)

The existing implementation incorrectly used "Token" for all authentication, which worked for API keys but was wrong for temporary tokens.

Changes:

There are no breaking changes to current apps.

  • Added AuthMethod enum to distinguish between API keys and temporary tokens
  • Updated Deepgram struct to use the new authentication system (by default it'll still use API keys)
  • Added Deepgram::with_temp_token() constructor for temporary token authentication
  • Use new auth logic in websocket
  • Added authentication documentation to README
  • Added tests for the new authentication logic

All existing tests pass, and the change is backwards compatible for API usage patterns.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update or tests (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING.md doc
  • I have added tests and/or examples that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

@jpvajda jpvajda requested review from jcdyer and jpvajda June 27, 2025 14:03
Copy link
Contributor

@jcdyer jcdyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this contribution. It looks good. I don't think we want to commit to supporting RedactedString or AuthMethod as part of the public API at this point.

@thisislvca
Copy link
Contributor Author

Good point, I initially made them public so I could extend it if I ever needed to, but it doesn't make sense at this stage you're right

@thisislvca thisislvca requested a review from jcdyer June 27, 2025 20:43
@jcdyer jcdyer merged commit 55f6e7f into deepgram:main Jun 30, 2025
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants