slack-php-api icon indicating copy to clipboard operation
slack-php-api copied to clipboard

Add refresh_token to OauthV2Access.php

Open b-sicard opened this issue 1 year ago • 6 comments

As far as I can see, there is no possibility of using the oauthV2Access method for token refresh.

Can you add it?

// JoliCode\Slack\Api\Endpoint\OauthV2Access

    protected function getQueryOptionsResolver(): \Symfony\Component\OptionsResolver\OptionsResolver
    {
        $optionsResolver = parent::getQueryOptionsResolver();
        $optionsResolver->setDefined(['client_id', 'client_secret', 'code', 'redirect_uri', 'grant_type', 'refresh_token']);
        $optionsResolver->setDefaults([]);
        $optionsResolver->addAllowedTypes('client_id', ['string']);
        $optionsResolver->addAllowedTypes('client_secret', ['string']);
        $optionsResolver->addAllowedTypes('code', ['string']);
        $optionsResolver->addAllowedTypes('redirect_uri', ['string']);
        $optionsResolver->addAllowedTypes('grant_type', ['string']);
        $optionsResolver->addAllowedTypes('refresh_token', ['string']);

        return $optionsResolver;
    }

b-sicard avatar Jul 03 '24 08:07 b-sicard

Hello! Thanks for reporting this issue.

It looks like it's missing from Slack OpenApi definition:

https://github.com/jolicode/slack-php-api/blob/31a49b5f54049a1ebb001de2545aff0500d4fdd6/resources/slack-openapi.json#L19403-L19440

That's why it's not allowed in OauthV2Access.

The only way to fix this is to create a new patch: https://github.com/jolicode/slack-php-api/blob/31a49b5f54049a1ebb001de2545aff0500d4fdd6/docs/4-updating-sdk.md#generating-a-new-patch (because there specification is really not good, we keep a list of patches to improve it before building the PHP client).

Would you be available to give it a try?

Thanks

damienalexandre avatar Jul 03 '24 08:07 damienalexandre

Okay, I'll look into it.

Will it be quickly updated after that? Because I need it for a project.

b-sicard avatar Jul 03 '24 13:07 b-sicard

Yes we can release a new version as soon as it's done 👍

damienalexandre avatar Jul 03 '24 13:07 damienalexandre

I can't push my branch to make a pull request.

Sorry, first time contributing to a project, I discover ^^

b-sicard avatar Jul 03 '24 14:07 b-sicard

Welcome to the open-source world :tada:

To be able to contribute, you have to work on a "fork": https://github.com/jolicode/slack-php-api/fork

It's this fork you must work on (create branches, make changes, etc).

Then when ready, Github will display a button to open a Pull Request on the main project.

damienalexandre avatar Jul 03 '24 14:07 damienalexandre

Thank you very much.

All done!

b-sicard avatar Jul 03 '24 15:07 b-sicard