Missing refresh token when using client credentials

Open
#116 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
50/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
ruby

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.

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.

Dominant language
Ruby
Stars
5
Forks
8
Avg merge
11h 9m
Merged PRs (30d)
24

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/kiota-ruby

All issues in microsoft/kiota-ruby

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.