Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

App managed caching mechanism #25

@rbclark

Description

@rbclark

Hello!

I am utilizing this library as part of an application which needs to allow users to navigate between different pages without requiring them to re-authenticate between every page load. In order to do this I need the ability to store the token information between requests into the database and then reload the data later on. My code is currently as follows:

context = MicrosoftKiotaAuthenticationOAuth::AuthorizationCodeContext.new(
  "common", # tenant_id
  "", # client_id
  "", # client_secret
  "http://localhost:3000/callback", # redirect_uri
  params[:code]
)

authentication_provider = MicrosoftGraphCore::Authentication::OAuthAuthenticationProvider.new(context, nil, nil)

adapter = MicrosoftGraph::GraphRequestAdapter.new(authentication_provider)
client = MicrosoftGraph::GraphServiceClient.new(adapter)
client.users.get.resume

This works fine but requires me to redirect the user to every single time to approve the request before a call which is far from ideal. I have an encrypted database table to store the token, how can I hook into this library to extract and then restore the token for subsequent requests? I don't see any way to retrieve or set the cached_token for the OAuthAuthenticationProvider or any of the other classes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions