Skip to content
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

What is the "request" object? #85

Open
straeter opened this issue Dec 18, 2024 · 2 comments
Open

What is the "request" object? #85

straeter opened this issue Dec 18, 2024 · 2 comments
Assignees

Comments

@straeter
Copy link

Describe the bug

from paddle_billing.Notifications import Secret, Verifier

integrity_check = Verifier().verify(request, Secret('WEBHOOK_SECRET_KEY'))

---> what is this mysterious "request" object? Is it from fastapi or any other library or is it defined in the library itself? At least flask "request" object did not work.

(it is not a bug but the issue categories were very limited)

Steps to reproduce

from flask import request
...
@app.route('/test', methods=['POST']:
def test():
integrity_check = Verifier().verify(request, Secret('WEBHOOK_SECRET_KEY'))

Expected behavior

verify the request

Code snippets

No response

Python version

Python 3.12

SDK version

paddle-python-sdk 1.01

API version

Paddle Version 1

Additional context

No response

@davidgrayston-paddle
Copy link
Contributor

Hello @straeter 👋

Thank you for raising this issue.

The Verifier().verify() method currently supports any request object matching the paddle_billing.Notifications.Requests.Request protocol, which covers major libraries such as Flask and Django.

class Request(Protocol):
    body: Optional[bytes]
    content: Optional[bytes]
    data: Optional[bytes]
    headers: Headers

I've checked that Flask v3.1.0 requests can be verified, so the issue could be related to the time drift check. By default the max variance is 5 seconds, so you could try increasing this to rule it out as the cause, e.g. Verifier(seconds).verify(request, Secret('WEBHOOK_SECRET_KEY'))

In future we may introduce dedicated convenience methods to make this easier to use, but in the meantime, if you continue to experience this issue, please let us know.

@davidgrayston-paddle davidgrayston-paddle self-assigned this Dec 19, 2024
@straeter
Copy link
Author

@davidgrayston-paddle thank you, this fixed it!

(I think it would still help to add a bit documentation about the request object)

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

No branches or pull requests

2 participants