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

Fido2Methods.CreationOptionsWithChallengeTimeoutInMinutes not working #940

Open
pionl opened this issue Nov 30, 2024 · 0 comments
Open

Fido2Methods.CreationOptionsWithChallengeTimeoutInMinutes not working #940

pionl opened this issue Nov 30, 2024 · 0 comments
Labels
status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience

Comments

@pionl
Copy link

pionl commented Nov 30, 2024

Describe the bug

Hi,

I'm unable to call a request on CreationOptionsWithChallengeTimeoutInMinutes due an error in the SDK. It forcess us to set ChallengeTimeoutInMinutes but it still does not work.

By the docs / graph explorer usage its should not required.

If I do not set the parameter, it crashes

  var response = await client.GraphService.Users[externalUserId]
            .Authentication.Fido2Methods.CreationOptionsWithChallengeTimeoutInMinutes
            .GetAsync();

If I set the parameter, it crashes

  var response = await client.GraphService.Users[externalUserId]
            .Authentication.Fido2Methods.CreationOptionsWithChallengeTimeoutInMinutes
            .GetAsync(r =>
            {
                r.Options.WithAppOnly();
                r.QueryParameters.ChallengeTimeoutInMinutes = 5;
            });

Thank you,

Expected behavior

The request should work with and without challange in minutes being set.

How to reproduce

Use the code I've attached and try the request.

SDK Version

5.88.0-preview

Latest version known to work for scenario above?

No response

Known Workarounds

  1. Copy the contents of generated code
  2. Remove code that sets path (challengeTimeoutInMinutes=@challengeTimeoutInMinutes){?challengeTimeoutInMinutes*}
  3. Run the request
        var requestBuilder = client.GraphService.Users[externalUserId].Authentication.Fido2Methods;

        var creationOptionsBuilder = new CreationOptionsBuilder(
            (requestBuilder.ToGetRequestInformation().PathParameters as Dictionary<string, object>)!,
            client.GraphService.RequestAdapter
        );
        var response = await creationOptionsBuilder.GetAsync();

Debug output

Click to expand log
Microsoft.Graph.Beta.Models.ODataErrors.ODataError: {"Message":"An error has occurred.","ExceptionMessage":"Missing the value of the parameter 'challengeTimeoutInMinutes' in the function 'creationOptions' calling.","ExceptionType":"System.InvalidOperationException","StackTrace":"   at Microsoft.AspNet.OData.Routing.ODataPathSegmentHandler.TranslateNode(Object node, String functionName, String parameterName)\r\n   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)\r\n   at 

Configuration

  • OS: Mac, Apple sillicon

Other information

Code i "created"
namespace MicrosoftGraph.Requests;

#pragma warning disable CS0618
using Microsoft.Kiota.Abstractions.Serialization;
using Microsoft.Kiota.Abstractions;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using System.Threading;
using System;

/// <summary>
/// Provides operations to call the creationOptions method.
/// Until https://github.com/microsoftgraph/msgraph-beta-sdk-dotnet/issues/940
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")]
public partial class Fido2CreationOptionsBuilder : BaseRequestBuilder
{
    /// <summary>
    /// Instantiates a new <see cref="Fido2CreationOptionsBuilder"/> and sets the default values.
    /// </summary>
    /// <param name="pathParameters">Path parameters for the request</param>
    /// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
    public Fido2CreationOptionsBuilder(Dictionary<string, object> pathParameters,
        IRequestAdapter requestAdapter) : base(requestAdapter,
        "{+baseurl}/users/{user%2Did}/authentication/fido2Methods/creationOptions",
        pathParameters)
    {
    }

    /// <summary>
    /// Instantiates a new <see cref="Fido2CreationOptionsBuilder"/> and sets the default values.
    /// </summary>
    /// <param name="rawUrl">The raw URL to use for the request builder.</param>
    /// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
    public Fido2CreationOptionsBuilder(string rawUrl, IRequestAdapter requestAdapter) :
        base(requestAdapter,
            "{+baseurl}/users/{user%2Did}/authentication/fido2Methods/creationOptions",
            rawUrl)
    {
    }

    /// <summary>
    /// Retrieve creation options required to generate and register a Microsoft Entra ID-compatible passkey. Self-service operations aren&apos;t supported.  
    /// Find more info here <see href="https://learn.microsoft.com/graph/api/fido2authenticationmethod-creationoptions?view=graph-rest-beta" />
    /// </summary>
    /// <returns>A <see cref="global::Microsoft.Graph.Beta.Models.WebauthnCredentialCreationOptions"/></returns>
    /// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
    /// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
    /// <exception cref="global::Microsoft.Graph.Beta.Models.ODataErrors.ODataError">When receiving a 4XX or 5XX status code</exception>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
    public async Task<global::Microsoft.Graph.Beta.Models.WebauthnCredentialCreationOptions?> GetAsync(
        Action<RequestConfiguration<global::Microsoft.Graph.Beta.Users.Item.Authentication.Fido2Methods.
                CreationOptionsWithChallengeTimeoutInMinutes.CreationOptionsWithChallengeTimeoutInMinutesRequestBuilder.
                CreationOptionsWithChallengeTimeoutInMinutesRequestBuilderGetQueryParameters>>? requestConfiguration =
            default, CancellationToken cancellationToken = default)
    {
#nullable restore
#else
        public async Task<global::Microsoft.Graph.Beta.Models.WebauthnCredentialCreationOptions> GetAsync(Action<RequestConfiguration<CreationOptionsBuilder.CreationOptionsWithChallengeTimeoutInMinutesRequestBuilderGetQueryParameters>> requestConfiguration
 = default, CancellationToken cancellationToken = default)
        {
#endif
        var requestInfo = ToGetRequestInformation(requestConfiguration);
        var errorMapping = new Dictionary<string, ParsableFactory<IParsable>>
        {
            { "XXX", global::Microsoft.Graph.Beta.Models.ODataErrors.ODataError.CreateFromDiscriminatorValue },
        };
        return await RequestAdapter.SendAsync<global::Microsoft.Graph.Beta.Models.WebauthnCredentialCreationOptions>(
            requestInfo,
            global::Microsoft.Graph.Beta.Models.WebauthnCredentialCreationOptions.CreateFromDiscriminatorValue,
            errorMapping, cancellationToken).ConfigureAwait(false);
    }

    /// <summary>
    /// Retrieve creation options required to generate and register a Microsoft Entra ID-compatible passkey. Self-service operations aren&apos;t supported.  
    /// </summary>
    /// <returns>A <see cref="RequestInformation"/></returns>
    /// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
    public RequestInformation ToGetRequestInformation(
        Action<RequestConfiguration<global::Microsoft.Graph.Beta.Users.Item.Authentication.Fido2Methods.
                CreationOptionsWithChallengeTimeoutInMinutes.CreationOptionsWithChallengeTimeoutInMinutesRequestBuilder.
                CreationOptionsWithChallengeTimeoutInMinutesRequestBuilderGetQueryParameters>>? requestConfiguration =
            default)
    {
#nullable restore
#else
        public RequestInformation ToGetRequestInformation(Action<RequestConfiguration<CreationOptionsBuilder.CreationOptionsWithChallengeTimeoutInMinutesRequestBuilderGetQueryParameters>> requestConfiguration
 = default)
        {
#endif
        var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters);
        requestInfo.Configure(requestConfiguration);
        requestInfo.Headers.TryAdd("Accept", "application/json");
        return requestInfo;
    }

    /// <summary>
    /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored.
    /// </summary>
    /// <returns>A <see cref="Fido2CreationOptionsBuilder"/></returns>
    /// <param name="rawUrl">The raw URL to use for the request builder.</param>
    public global::Microsoft.Graph.Beta.Users.Item.Authentication.Fido2Methods.
        CreationOptionsWithChallengeTimeoutInMinutes.CreationOptionsWithChallengeTimeoutInMinutesRequestBuilder
        WithUrl(string rawUrl)
    {
        return new global::Microsoft.Graph.Beta.Users.Item.Authentication.Fido2Methods.
            CreationOptionsWithChallengeTimeoutInMinutes.CreationOptionsWithChallengeTimeoutInMinutesRequestBuilder(
                rawUrl, RequestAdapter);
    }

    /// <summary>
    /// Retrieve creation options required to generate and register a Microsoft Entra ID-compatible passkey. Self-service operations aren&apos;t supported.  
    /// </summary>
    [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")]
    public partial class CreationOptionsWithChallengeTimeoutInMinutesRequestBuilderGetQueryParameters
    {
       
    }

    /// <summary>
    /// Configuration for the request such as headers, query parameters, and middleware options.
    /// </summary>
    [Obsolete(
        "This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")]
    [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")]
    public partial class CreationOptionsWithChallengeTimeoutInMinutesRequestBuilderGetRequestConfiguration :
        RequestConfiguration<global::Microsoft.Graph.Beta.Users.Item.Authentication.Fido2Methods.
            CreationOptionsWithChallengeTimeoutInMinutes.CreationOptionsWithChallengeTimeoutInMinutesRequestBuilder.
            CreationOptionsWithChallengeTimeoutInMinutesRequestBuilderGetQueryParameters>
    {
    }
}
#pragma warning restore CS0618
@pionl pionl added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Nov 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience
Projects
None yet
Development

No branches or pull requests

1 participant