calcinai / xero-php

A php library for the Xero API, with a cleaner OAuth interface and ORM-like abstraction.
MIT License
359 stars 261 forks source link

getTenants and getResourceOwner token types #748

Open leereichardt opened 4 years ago

leereichardt commented 4 years ago

Both getTenants and getResourceOwner require to us pass-through the token interface. We can pass through the same token object to both, however, getResourceOwner complains it's expecting \League\OAuth2\Client\Token\AccessToken rather than the \League\OAuth2\Client\Token\AccessTokenInterface provided.

This is mainly in the IDE hinting so more a type casting and DocBlock update. Let me know if what I'm saying is right and I do a PR for you if you'd like

calcinai commented 4 years ago

Yeah–from what I can see it should be the interface...

That change will need to be made be over here

leereichardt commented 4 years ago

Cool. I'll try to do a PR over there too.

ljenningsVS commented 4 years ago

@leereichardt Did you get around to getting this change into a PR? getTenants fails for me using the example code for the reasons you mentioned above.

ljenningsVS commented 4 years ago

@calcinai Another quick point relating to this.

AccessTokenInterface was added to league/oauth-client in v2.4.0 which requires PHP5.6 which breaks the php55 support of this package. Am I missing a work around here or is the php55 compatability not active anymore?

Cheers

calcinai commented 4 years ago

@ljenningsVS Great question. I think we're going to have to drop 5.5, it was there (selfishly) for a legacy GAE project.

ljenningsVS commented 4 years ago

@calcinai No worries i have a work around for now by crafting the genTenant call manually like

private function getTenantIds($provider, $token)
    {
        $request = $provider->getAuthenticatedRequest(
            'GET',
            $provider->getTenantsUrl(),
            $token
        );

        $response = $provider->getResponse($request);

        $tenants = [];

        foreach ($response as $tenantData) {
            $tenants[] = XeroTenant::fromArray($tenantData);
        }

        return $tenants;
    }

This is a valid work around for me for the moment anyway. Do you forsee any other issues if I lock my version of this pacakge to the current tag?

leereichardt commented 4 years ago

Whoops. May have forgotten about this 😅 PR here: https://github.com/calcinai/oauth2-xero/pull/8