Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default Client Options #712

Open
maisarissi opened this issue Aug 22, 2023 · 2 comments
Open

Default Client Options #712

maisarissi opened this issue Aug 22, 2023 · 2 comments

Comments

@maisarissi
Copy link

maisarissi commented Aug 22, 2023

I used Kiota to generate a customized .NET client library targeting the Graph API and have added the Graph .NET core library to my project.

When creating a new BaseGraphRequestAdapter users can pass their own clientOptions what might be a strange scenario since the clientOption is used to inject telemetry data around SDK versioning.

We should have a default client option where in an absence of a user using service library version, we set up the core library values as default, so when creating a new adapter, the core version will be sent to out telemetry.

@andrueastman
Copy link
Member

andrueastman commented Aug 23, 2023

After taking a look at this, the only mandatory parameter for BaseGraphRequestAdapter is the authprovider similar to the Kiota abstractions HttpClientRequestAdapter.
It is possible to not pass the clientOptions and the SDK will initialize a default as captured in this test

Currently, the initialization with core library is as below.

var authProvider = new AzureIdentityAuthenticationProvider(interactiveBrowserCredential, scopes: scopes);
var graphClient = new ApiClient(new BaseGraphRequestAdapter(authProvider));// Create the API client
var messages = await graphClient.Me.Messages.GetAsync();

@sebastienlevert
Copy link

Adding more context.

We should have a RequestAdapter factory on core that would provide something like this:

var scopes = new [] { "User.Read" };

var options = new DeviceCodeCredentialOptions
{
    ClientId = "..."
};

var credential = new DeviceCodeCredential(options);

// For inspiration only. Please provide better naming :D
var client = new TinyGraphClient(MicrosoftGraphClientCore.CreateRequestAdapter(credential, scopes));

@andrueastman andrueastman removed their assignment Apr 3, 2024
@shemogumbe shemogumbe assigned shemogumbe and unassigned shemogumbe Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants