首页 > 其他分享 >ABP Framework Consuming HTTP APIs from a .NET Client

ABP Framework Consuming HTTP APIs from a .NET Client

时间:2024-08-29 14:04:30浏览次数:6  
标签:44333 ClientSecret Consuming HTTP APIs App ClientId BookStore Client

1、Add BookStore_App section int BookStore.DbMigrator\appsettings.json
"BookStore_App": {
  "ClientId": "BookStore_App",
  "ClientSecret": "1q2w3e*",
  "RootUrl": "https://localhost:44333"
}

2、Add Client in BookStore.Domain\OpenIddict\OpenIddictDataSeedContributor.cs
// BookStoreApp Client
var bookStoreAppClientId = configurationSection["BookStore_App:ClientId"];
if (!bookStoreAppClientId.IsNullOrWhiteSpace())
{
    var bookStoreAppRootUrl = configurationSection["BookStore_App:RootUrl"]?.TrimEnd('/');
    await CreateApplicationAsync(
        name: bookStoreAppClientId,
        type: OpenIddictConstants.ClientTypes.Confidential,
        consentType: OpenIddictConstants.ConsentTypes.Implicit,
        displayName: "BookStoreApp",
        scopes: commonScopes,
        grantTypes: [OpenIddictConstants.GrantTypes.Password,],
        secret: configurationSection["BookStore_App:ClientSecret"] ?? "1q2w3e*",
        redirectUri: $"{bookStoreAppRootUrl}/authentication/login-callback"
    );
}

3、Run DbMigrator project

4、Add ClientSecret to BookStore\test\BookStore.HttpApi.Client.ConsoleTestApp\appsettings.json
{
  "RemoteServices": {
    "Default": {
      "BaseUrl": "https://localhost:44333"
    }
  },
  "IdentityClients": {
    "Default": {
      "GrantType": "password",
      "ClientId": "BookStore_App",
      "UserName": "admin",
      "UserPassword": "1q2w3E*",
      "ClientSecret": "1q2w3e*",
      "Authority": "https://localhost:44333",
      "Scope": "BookStore"
    }
  }
}

5、Run API and test again

 

  1. Add BookStore_App section int BookStore.DbMigrator\appsettings.json

"BookStore_App": { "ClientId": "BookStore_App", "ClientSecret": "1q2w3e*", "RootUrl": "https://localhost:44333" }

  1. Add Client in BookStore.Domain\OpenIddict\OpenIddictDataSeedContributor.cs

// BookStoreApp Client var bookStoreAppClientId = configurationSection["BookStore_App:ClientId"]; if (!bookStoreAppClientId.IsNullOrWhiteSpace()) { var bookStoreAppRootUrl = configurationSection["BookStore_App:RootUrl"]?.TrimEnd('/'); await CreateApplicationAsync( name: bookStoreAppClientId, type: OpenIddictConstants.ClientTypes.Confidential, consentType: OpenIddictConstants.ConsentTypes.Implicit, displayName: "BookStoreApp", scopes: commonScopes, grantTypes: [ OpenIddictConstants.GrantTypes.Password, ], secret: configurationSection["BookStore_App:ClientSecret"] ?? "1q2w3e*", redirectUri: $"{bookStoreAppRootUrl}/authentication/login-callback" ); }

  1. Run DbMigrator project

  2. Add ClientSecret to BookStore\test\BookStore.HttpApi.Client.ConsoleTestApp\appsettings.json

{ "RemoteServices": { "Default": { "BaseUrl": "https://localhost:44333" } }, "IdentityClients": { "Default": { "GrantType": "password", "ClientId": "BookStore_App", "UserName": "admin", "UserPassword": "1q2w3E*", "ClientSecret": "1q2w3e*", "Authority": "https://localhost:44333", "Scope": "BookStore" } } }

5 Run API and test again

标签:44333,ClientSecret,Consuming,HTTP,APIs,App,ClientId,BookStore,Client
From: https://www.cnblogs.com/xinzheng/p/18386535

相关文章

  • gyp GET https://nodejs.org/download/release/v20.15.0/node-v20.15.0-headers.tar.g
    如图我执行yarn关于node会报错:gyphttpGEThttps://nodejs.org/download/release/v20.15.0/node-v20.15.0-headers.tar.gzgyphttpfetchGEThttps://nodejs.org/download/release/v20.15.0/node-v20.15.0-headers.tar.gzattempt1failedwithETIMEDOUTgypWARNins......
  • 服务器出现 HTTP 错误代码,及解决方法
    HTTP400-请求无效HTTP401.1-未授权:登录失败HTTP401.2-未授权:服务器配置问题导致登录失败HTTP401.3-ACL禁止访问资源HTTP401.4-未授权:授权被筛选器拒绝HTTP401.5-未授权:ISAPI或CGI授权失败HTTP403-禁止访问HTTP403-对Internet服务管理器的......
  • nginx之http跳转https
    http跳转https实现示例:ssl配置参考“https”实现文章法一:2个虚拟主机配置:[[email protected]]#vim/apps/nginx4/conf/conf.d/test.confserver{listen443ssl;#listen80;server_namewww.magedu.org;root/data/site14/;......
  • nginx之ssl认证(https访问)
    ngx_http_ssl_modulengx_http_ssl_module模块:sslon|off;为指定虚拟机启用HTTPSprotocol,建议用listen指令代替ssl_certificatefile; 当前虚拟主机使用PEM格式的证书文件ssl_certificate_keyfile;......
  • Python编码系列—Python中的HTTPS与加密技术:构建安全的网络通信
    ......
  • docker pull通过http代理下载镜像
    有时服务器没有外网环境,要pulldocker镜像就没办法了,只能考虑通过代理或离线下载好导入的方式进行,这里记录下通过http代理的方式。一、dockerpull通过http代理下载镜像1.修改/etc/systemd/system/multi-user.target.wants/docker.servicevi/etc/systemd/system/multi-user.ta......
  • 协议汇总 TCP、UDP、Http、Socket、Web Scoket、Web Service、WCF、API
    TCP:(1)位于OSI传输层,基于soap(信封)协议;(2)数据格式是xml、Json;(3)是面向连接的,需要先建立连接;(4)TCP协议是一个可靠的传输协议,它可以保证传输的一个正确性,保证我们的不丢包不重复,而且数据是按顺序到达的,保证不丢包(握手需要三次,挥手却要四次);(5)典型的TCP/IP之上的协议有FTP、......
  • nginx访问控制、用户认证、https
    环境rockylinux9虚拟机,时钟同步已完成,基本工具,命令已安装192.168.100.111nginx服务器192.168.100.112客户端访问192.168.100.114客户端访问nginx已经配置完成做了平滑升级一、nginx访问控制默认允许所有主机访问stub_status模块stub_status模块主要作用于查看ng......
  • http和https
    C++遍历数组的有几种方式?answer:1、下标遍历,传统的遍历方式2、指针遍历,数组本身也是指针,所以可以使用指针进行遍历3、for(range-based),用于同一类型的范围数据进行遍历4、迭代器,使用迭代器iter的函数集可以进行较快的遍历,自动回收。http和https的区别?answer:主要区别后置增加......
  • 【Shell脚本】监控 httpd 的进程数,根据监控情况做相应处理
    #!/bin/bash################################################################################################################################需求:#1.每隔10s监控httpd的进程数,若进程数大于等于500,则自动重启Apache服务,并检测服务是否重启成功#2.若未成功则需......