Skip to content

Conversation

@tylerburdsall
Copy link
Contributor

Reworked from #22 to instead generate a JSON string that will be interpolated by the host to support genereating disposable tokens from functions.

Original PR description:

Momento currently has examples on how to make a token vending machine for temporary, scoped Momento tokens. But those examples are typically based around some form of a cloud deployment, such as AWS using API Gateway backed by a Lambda function and aren't protected by auth.

This PR ports over the functionality for vending temporary tokens using Momento Functions instead. This gives you a powerful, fast way to generate specific tokens for your customers without having to manage CloudFormation stacks, racking up AWS bills, etc. as well as having the confidence in knowing your function's endpoint is secure.

log::error!("Failed to generate token: {e:?}");
let status = match &e {
token::GenerateDisposableTokenError::TokenError(token_error) => match token_error {
momento_functions_wit::host::momento::functions::token::TokenError::InvalidArgument(_) => 400,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: use momento_functions_wit::host::momento::functions::token::TokenError so you can tidy this block's line noise. There aren't any other TokenError names that would be confusing, and you still stay below 100 lines I think :-p

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tylerburdsall tylerburdsall merged commit 18f201c into main Nov 26, 2025
1 check passed
@tylerburdsall tylerburdsall deleted the feat/generate-disposable-token branch November 26, 2025 21:31
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.

4 participants