Skip to content

Commit

Permalink
Tweak the device identifier attachment logic
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinchalet committed Feb 10, 2025
1 parent f937100 commit da82d11
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -660,17 +660,20 @@ public ValueTask HandleAsync(ProcessAuthenticationContext context)
}

// VK ID requires attaching a non-standard "device_id" parameter to all token requests.
//
// This parameter is either resolved from the authorization response (for the authorization
// code or hybrid grants) or manually provided by the application for other grant types.
else if (context.Registration.ProviderType is ProviderTypes.VkId)
{
if (!context.Properties.TryGetValue(VkId.Properties.DeviceId, out string? identifier) ||
string.IsNullOrEmpty(identifier))
context.TokenRequest["device_id"] = context.GrantType switch
{
throw new InvalidOperationException(SR.GetResourceString(SR.ID0467));
}
GrantTypes.AuthorizationCode or GrantTypes.Implicit => context.Request["device_id"],

_ when context.Properties.TryGetValue(VkId.Properties.DeviceId, out string? identifier) &&
!string.IsNullOrEmpty(identifier) => identifier,

context.TokenRequest["device_id"] = identifier;
_ => throw new InvalidOperationException(SR.GetResourceString(SR.ID0467))
};
}

return default;
Expand Down

0 comments on commit da82d11

Please sign in to comment.