Weble / ZohoBooksApi

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Always get an exception

Fadhilamadan opened this issue · comments

Why I always get an exception from Grand Code.

First:
"Weble\ZohoClient\Exception\GrantCodeNotSetException"

And then I set with setGrantCode("..."), and get this exception.

Second:
"Weble\ZohoClient\Exception\InvalidGrantCodeException"

Basically I already have RefreshToken and that I know at the moment is Grand Code can't be statically.

Thanks.

Hi! Can you check this discussion and tell me if it helps?
Thanks!

Thanks @Skullbock
I just put offlineMode() and must be sequentially.

Like this, and it work for me.

protected $organizationClient;

public function __construct()
{
    $authClient = new OAuthClient(env('ZOHO_CLIENT_ID'), env('ZOHO_CLIENT_SECRET'));
    $authClient->offlineMode();
    $authClient->setRefreshToken(env('ZOHO_REFRESH_TOKEN'));
    $authClient->setGrantCode($authClient->getAccessToken());

    $this->organizationClient = new Client($authClient);
    $this->organizationClient->setOrganizationId(env('ZOHO_ORGANIZATION_ID'));
}

public function zohoBooks()
{
    return new ZohoBooks($this->organizationClient);
}

Great to hear that.
OAuth2 sometimes is really bothersome :)