Closed Allmight3 closed 4 years ago
I'm seeing the same thing. 403 error returned from the call to
rsp = self._run_request(('https://www.safeway.com/iaaw/service/' 'authenticate'), json_data=login_data, headers=headers)
It appears Safeway has started using Okta for login (the login form now posts to albertsons.okta.com
). I'll need to do some investigation.
Any update? Does the new system use a captcha?
@jamesderlin for now I am just using a headless selenium chrome browser to clip them.
Not as nice but it'll have to do until @smkent has a chance to fix the login.
Looks like somebody figured it out. I may try to merge the new auth part.
Just created PR #21 that updates for the new authentication method. It's basically as described in the previous link, though the blog post glossed over many critical details.
I'm not sure if deleting ORIGIN completely did the trick. It was able to clip, but not all. I visited the safeway J4U website and there's still a lot of unclipped coupons. Especially in the Personalized Price and Special Offer. After you click load more, it seems to stopped clipping those coupons all together.
@tieubao81, I think there's a secondary issue with an API change. The new URL for the coupon gallery is https://www.safeway.com/abs/pub/web/j4u/api/ecomgallery, and it has a different JSON format. I initially reworked the code to use the new ecomgallery URL before finding out that the old URL still worked with the ORIGIN header removed. I thought all the coupons were being clipped with the old URL, but it looks like they may not be if you're still getting unclipped coupons. It's not hard to switch to the new URL, just a couple minor changes to address the new JSON layout.
Took another look at the unclipped coupons and it looks like they are actually being clipped, but show up as unclipped on the browser due to the new use of localstorage caching of the coupon list. To force the cache to clear, I deleted all my cookies and logged in again and the coupons that were previously showing unclipped were actually clipped. So I think the coupon clipper is working fine.
For what it's worth, I pulled @jmacknet's Okta changes in PR21 into my fork of this project and it's working fine. Thanks, jmacknet!
Thanks to @jmacknet for providing a fix in #21!
The original error that comes up:
I took a look at why there was a JSON error and it appears that there is no longer a successful request being sent to login. Here is a print of the rsp.content:
I'm using the latest commit I see from Feb 19 and I am using python 3.7.5.