Weble / ZohoClient

11 stars 7 forks source link

Suggestion: change to use PHP League's OAuth 2.0 Client #2

Closed bluec closed 3 years ago

bluec commented 4 years ago

Thanks for making this client it's great to be able to use it with your ZohoBooks API client.

I wondered whether you have considered building this as a provider on top of the thephpleague/oauth2-client?

It seems this would hugely simplify the codebase (an oauth2-client provider can be as simple as a single class), would standardise things a little, and would also take advantage of the underlying support and ongoing updates from the phpleague package.

Skullbock commented 4 years ago

Hi @bluec yes i thought about it, but when i tried, i saw that our friends at zoho have some strange behavior going on with their oauth2 apis, which was causing the client to fail.

I'm open to PRs though. Otherwise, i'll try to get back to to it the net time i need this library in one of my projects :)

bluec commented 4 years ago

Haha it's not like Zoho to do strange things! I may take a look sometime, will update this ticket or make a PR if I have anything to show.

tm1000 commented 4 years ago

I spent about an hour looking over two similar projects: https://github.com/asadku34/oauth2-zoho and https://github.com/shahariaazam/zoho-oauth2

And using that I was able to figure out the implementation logic for PHP League's Oauth 2.0 client. I've got the three classes in Weble ZohoClient, next up is just putting that back into Weble\ZohoClient\OAuthClient so that this upgrade could technically be pretty transparent.

At this point I at least know it works. Hopefully I'll have something to contribute tomorrow as using this library would be more beneficial for our work

tm1000 commented 4 years ago

Some stuff im not clear on @Skullbock, what is parseGrantTokenFromUrl used for. There are no examples, its input is pulled from UriInterface instead of a string. So perhaps this is something you use internally at your company?

Skullbock commented 4 years ago

Hi! That's a convenience method for the developer to use in the page when he lands after the redirection from zoho, that allows to get the code param from the url (the grant token).

I'm using the uri interface from the PSR-7 because i love standardization like that and it's what most framework use anyway https://github.com/php-fig/http-message

Nice news on the oauth2 stuff, if you want to send a PR, feel free to do so so i can evaluate a new major version if needed and use it in the other packages!