-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add grantless operations #54
base: main
Are you sure you want to change the base?
Conversation
add possibility for grantless requests
@ericcj pinging you in case you didn't get notification and are interested! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks great thank you let's just simplify the config so it doesn't have separate lambdas for different types of tokens and if you could write a bit about how you tested it that would be appreciated i'd like to release a new version including this
@@ -47,6 +47,12 @@ require 'fulfillment-outbound-api-model' | |||
Rails.cache.write("SPAPI-TOKEN-#{access_token_key}", token[:access_token], expires_in: token[:expires_in] - 60) | |||
end | |||
config.get_access_token = -> (access_token_key) { Rails.cache.read("SPAPI-TOKEN-#{access_token_key}") } | |||
|
|||
# optional lambdas for caching grantless LWA access token instead of requesting it each time, e.g.: | |||
config.save_grantless_access_token = -> (access_token_key, token) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the lambdas already take an "access_token_key" which is the cache key to save the token under, let's use the same lambdas just vary the key similar to what i did for RDT https://github.com/ericcj/amz_sp_api/pull/55/files#diff-e2f2fe4083a87c67a20260d6f13385b63f2b64f0cabdcdf4e2f332fa754fbb5bR16
that way we can also remove the indirection of using public_send as well
and after that change the only readme update needed should be to clarify that refresh_token isn't required if you want to use only using grantless operations.
@ericcj will do sometime in upcoming week! |
This pr checks whether request is being made to an endpoint which requires grantless access token.
Endpoints gathered from- https://developer-docs.amazon.com/sp-api/docs/grantless-operations
Relevant issues:
#38
#3
Tested with notification endpoints. Code is not affecting any of generated code parts, so that shouldn't be an issue.