ahmedsakr / wstrade-api

API Wrapper for Wealthsimple Trade

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

auth.on not dispatching gmail [Increased Cloudflare security]

PrashanthPillay opened this issue · comments

Hi so I've been using this API for about 3 months now and never had any issues with this before, but I tried running some code today and it seems as though auth.on no longer dispatches the gmail OTP. Not sure if this started occurring after the new update or if there was some change on WealthSimple's end.

You are absolutely right. The login API seems to have changed on their side last night. I'll try to push an update soon.

The issue seems to be with increased security. Their cloudflare seems to now be blocking requests through some firewall rules. This might take me a bit longer to figure out, but until now, this library never bothered maintaining and presenting cookies. This might be the issue now: cloudflare might be denying requests due to no cookies.

This is going to take more research and trial-and-error, time I don't have today unfortunately. I'll allocate time to work on this tomorrow.

Is there anything I can help with?

Is there anything I can help with?

Yes. I'm currently doing some school work and i plan on working on this later today. If you can do some research on what HTTP headers Cloudflare is examining for security reasons, that would be amazing!

I'm not sure if this is what you're looking for but I was looking through the code in the cloudflare docs repository and found this.
Screenshot_20210313-091926_Samsung Internet

So this might be the header change causing the issues.

Hey guys Wsimple (python version of wstrade-api) here I found a way to log in using a Cloudflare library. should be on branch api_v2 soon.

Great. Do you mind sharing the Cloudflare library name or how it solves the problem?

I found it here:
cloudflare-docs/products/firewall/src/content/cf-firewall-language/.
And I'm not sure if such a small change would cause the problem but it's the only change made recent enough to the cloudflare firewall that I could find since the ws api was working fine for me a week ago

the library cloudscraper, I don't know it exactly solves the problem :)

Thanks Yusuf. I've read a bit of the source code and overcoming the Cloudflare challenges doesn't seem to be a simple task.

The library also seems to utilize node execution, so it imposes requirements on both of our libraries: If I were to use it, i'd have to require the users of wstrade-api to also have python installed, and you would have to require your users to have node installed.

https://www.npmjs.com/package/cloudscraper I might have found a similar library on npm

Welp currently this is the only fix I found for it, so I guess I have no choice but for node to be a requirement from now on.

For sure, it's better for it to be working than not, hahah :)

I'm glad you found it. I'll try out the npm version of cloudscraper later today and I'll report back if it worked for me too.

P.S.: good job on the python version of this API. Great addition to the WS open-source community.

Just wanted to update that i got it working with the cloudscraping node module on npm. I'm prettying it up, testing all APIs, and I'll push an update likely tonight.

v1.7.1 has been pushed to npm with the fix! All is back working now.