【问题标题】:How to get user code for device code flow in identity server 4如何在身份服务器 4 中获取设备代码流的用户代码
【发布时间】:2020-08-14 16:05:46
【问题描述】:

我正在尝试使用已在 IdentityServer4 中实现的设备代码流,但在文档中,我找不到有关设备代码流的任何有用信息。我找到了一个设备代码流示例,但我不明白什么是用户代码,如何获取或保存它。

这是用于获取授权上下文的基本服务。

    private readonly IDeviceFlowInteractionService _interaction;

    public DeviceController(
        IDeviceFlowInteractionService interaction)
    {
        _interaction = interaction;
        _clientStore = clientStore;
        _resourceStore = resourceStore;
        _events = eventService;
        _logger = logger;
    }

    private async Task<DeviceAuthorizationViewModel> BuildViewModelAsync(string userCode, DeviceAuthorizationInputModel model = null)
    {
        var request = await _interaction.GetAuthorizationContextAsync(userCode);
        // Some code ...
        return null;
    }

正如您在上面看到的,我使用了具有参数 userCode 的 GetAuthorizationContext 但我不明白如何获取此代码?或保存在哪里。在文档中,我没有找到有关 UserCode 的任何信息。

【问题讨论】:

    标签: asp.net asp.net-core identityserver4


    【解决方案1】:

    Here is a sample application 由 IdentityServer 维护者之一构建,展示了如何利用 Device Flow。

    客户端将需要向设备授权端点发出请求以生成代码。如this file 的第 38 行所示,一旦生成了代码,它就会显示给用户。

    然后用户可以在您的 Web 应用程序上输入代码以提交到您在上面构建的DeviceController

    【讨论】:

      猜你喜欢
      • 2022-01-16
      • 2018-04-09
      • 2016-03-04
      • 1970-01-01
      • 2021-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-01
      相关资源
      最近更新 更多