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

[BUG] Async example wrong #59

Open
Kylmakalle opened this issue Oct 28, 2019 · 1 comment
Open

[BUG] Async example wrong #59

Kylmakalle opened this issue Oct 28, 2019 · 1 comment
Labels

Comments

@Kylmakalle
Copy link

Seems like session for validator creates only on __aenter__

File "inapppy/asyncio/appstore.py", line 47, in validate
    api_response = await self.post_json(receipt_json)
  File "inapppy/asyncio/appstore.py", line 30, in post_json
    async with self._session.post(
AttributeError: 'NoneType' object has no attribute 'post'

Working example for me

async with validator:
    validation_result = await validator.validate(...)
@Kylmakalle Kylmakalle added the bug label Oct 28, 2019
@gfx
Copy link

gfx commented Sep 20, 2024

Same here. I made a test code:

class AppStoreClient:
    async def verify_receipt(self, receipt_data: str) -> bool:
        async with AppStoreValidator(
            bundle_id=bundle_id,
            sandbox=sandbox,
        ) as validator:
            try:
                validation_result = await validator.validate(receipt=receipt_data)
                return validation_result.is_valid
            except InAppPyValidationError as ex:
                print(f"Validation error occurred: {ex.raw_response}", file=sys.stderr)
                return False

It doesn't make a request to the Apple server at all. Just because __aenter__ does not return self.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants