jolicode / slack-php-api

:hash: PHP Slack Client based on the official OpenAPI specification
https://jolicode.github.io/slack-php-api/
MIT License
221 stars 54 forks source link

Add refresh_token to OauthV2Access.php #172

Open benparker2 opened 2 days ago

benparker2 commented 2 days ago

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;
    }
damienalexandre commented 2 days ago

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

benparker2 commented 2 days ago

Okay, I'll look into it.

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

damienalexandre commented 2 days ago

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

benparker2 commented 2 days ago

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

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

damienalexandre commented 2 days ago

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.

benparker2 commented 2 days ago

Thank you very much.

All done!