microsoft / microsoft/kiota-ruby
Missing refresh token when using client credentials
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 5
- Forks
- 8
- Avg merge
- 11h 9m
- Merged PRs (30d)
- 24
Description
The access token doesn't have a refresh token if we use client_credentials as grant_type - however the OAuthAccessTokenProvider tries to refresh the token if it's expired instead of requesting a new one, which results in this error:
oauth2-2.0.9/lib/oauth2/access_token.rb:118:in `refresh': A refresh_token is not available (RuntimeError)
microsoft_kiota_authentication_oauth-0.8.0/lib/microsoft_kiota_authentication_oauth/oauth_access_token_provider.rb:66:in `block in get_authorization_token'
This happens here: https://github.com/microsoft/kiota-authentication-oauth-ruby/blob/main/lib/microsoft_kiota_authentication_oauth/oauth_access_token_provider.rb#L66
This could be addressed by simply checking if a refresh token is available here: https://github.com/microsoft/kiota-authentication-oauth-ruby/blob/main/lib/microsoft_kiota_authentication_oauth/oauth_access_token_provider.rb#L65
if token.expired? && !token.refresh_token.nil?
Then it would automatically request a new token instead of trying to refresh it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lib/microsoft_kiota_authentication_oauth/oauth_access_token_provider.rb around lines 65-66 and inspect how expired client-credentials tokens are handled. Reproduce the expired-token case and verify that a token without a refresh token requests a new access token instead of raising the reported refresh error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- authentication
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100