在文档中,它说我可以在代码中执行以下操作来进一步配置我的集成:
每个键都提供了一个代码示例和一个配置文件示例。
configuration.ReleaseStage = "development";
Run Code Online (Sandbox Code Playgroud)
我想做的是:
public static void Register(HttpConfiguration config)
{
var configuration = Bugsnag.ConfigurationSection.Configuration.Settings;
configuration.ReleaseStage = ConfigurationManager.AppSettings["Environment"];
config.UseBugsnag(configuration);
}
Run Code Online (Sandbox Code Playgroud)
但是,配置属性是只读的(没有设置器)。
另一种方法是将配置添加到 Web.config:
<bugsnag apiKey="your-api-key" releaseStage="development">
Run Code Online (Sandbox Code Playgroud)
问题是我正在从 AppSettings 读取我的环境,因此不能这样做。
是否可以在代码中进行配置,如果可以,如何进行?
更新:自从发布问题后,我在 GitHub 上发现了这个问题。
我无法使用 Postman 获得 IdentityServer4 PKCE 授权。
我使用在线工具创建了必要的部分:
选择一个随机字符串:
1234567890
获取其 SHA-256 哈希值:
c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f268646
Base64 编码散列以获得代码挑战:
Yzc3NWU3Yjc1N2VkZTYzMGNkMGFhMTExM2JkMTAyNjYxYWIzODgyOWNhNTJhNjQyMmFiNzgyODYyZjI2ODY0Ng==
在浏览器中,我导航到以下 URL,填写我的凭据并从碎片化的重定向 URL 中检索代码。
GET https://localhost:5000/connect/authorize
?client_id=pkceclient
&scope=openid
&response_type=code
&redirect_uri=https://jwt.ms
&state=abc
&nonce=xyz
&code_challenge=Yzc3NWU3Yjc1N2VkZTYzMGNkMGFhMTExM2JkMTAyNjYxYWIzODgyOWNhNTJhNjQyMmFiNzgyODYyZjI2ODY0Ng==
&code_challenge_method=S256
Run Code Online (Sandbox Code Playgroud)
在兑换令牌代码时,我传递了 code_verifier(SHA-256 哈希),但我的 IdentityServer 记录了以下错误:
“转换后的代码验证器与代码质询不匹配”。
POST https://localhost:5000/connect/token
client_id=pkceclient
grant_type=authorization_code
code:-CesrmjPYjdLdDd5AviOZpR6GdjjkZia_ZapoJdGUZI
redirect_uri=https://jwt.ms
code_verifier=c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f268646
Run Code Online (Sandbox Code Playgroud)
在他的博客文章中,作者使用以下代码生成零件。
var verifier = CryptoRandom.CreateRandomKeyString(64);
var challenge = verifier.ToCodeChallenge();
Run Code Online (Sandbox Code Playgroud)
但我在该ToCodeChallenge方法的存储库中找不到代码。
为什么我手动生成的质询与验证过程中使用的质询不匹配,我错过了什么?