microsoft-identity-web icon indicating copy to clipboard operation
microsoft-identity-web copied to clipboard

Add WithAuthenticationOptions extension method enables developers specify authentication properties when using Microsoft Graph SDK requests.

Open jennyf19 opened this issue 3 years ago • 0 comments

Why? We want clients to call Microsoft Graph with Pop + server nonce etc ... and, really override all the possible authentication options when using the Graph SDK.

What? Provide a new extension method on Microsoft Graph SDK Base request, in Microsoft.Identity.Web.MicrosoftGraph (and GraphBeta) that would take an Action<DownstreamRestApiOptions>

            GraphServiceClient graphServiceClient = serviceProvider.GetRequiredService<GraphServiceClient>();
            var users = await graphServiceClient.Users
                .Request()
                .WithAppOnly()
                .WithAuthenticationOptions(options => options.ProtocolScheme = "Pop")
                .GetAsync();
            Console.WriteLine($"{users.Count} users");

How? same principle as WithAppOnly and its implementation.

        /// <summary>
        /// Overrides authentication options for a given request.
        /// </summary>
        /// <typeparam name="T">Request</typeparam>
        /// <param name="baseRequest">Request.</param>
        /// <param name="overrideAuthenticationOptions">Delegate to override
        /// the authentication options</param>
        /// <returns>Base request</returns>
        public static T WithAuthenticationOptions<T>(this T baseRequest, 
            Action<DownstreamRestApiOptions> overrideAuthenticationOptions) where T : IBaseRequest
        {
            // TODO: implement
            throw new NotImplementedException();
        }

jennyf19 avatar Aug 14 '22 20:08 jennyf19