Telerik NuGet源加载服务索引失败报401未授权问题求助
问题现象
当前无法下载Telerik.UI.for.Xamarin NuGet包,将Package Source切换为Telerik NuGet时触发如下报错:
Unable to find package Telerik.UI.for.Xamarin with version (>= 2019.2.619.1) Found 1 version(s) in nuget.org [ Nearest version: 2015.3.1202 ] [Telerik Nuget] Unable to load the service index for source https://nuget.telerik.com/v3/index.json. Response status code does not indicate success: 401 (Unauthorized).
已在APPDATA目录下的nuget.config中添加访问凭据,配置如下:
<?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <clear /> <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> <add key="Telerik Nuget" value="https://nuget.telerik.com/v3/index.json" /> </packageSources> <packageSourceCredentials> <telerik> <add key="Username" value="*****" /> <add key="ClearTextPassword" value="*****" /> </telerik> </packageSourceCredentials> </configuration>

同时已手动在Windows凭据管理器中添加了https://nuget.telerik.com/nuget地址及对应凭据,仍无法解决问题。
修复方案
按以下步骤逐一排查修复:
- 修正
nuget.config中凭据节点的名称匹配问题
NuGet 要求packageSourceCredentials下的子节点名称必须和对应包源的key值完全一致,当前配置中包源key为Telerik Nuget,但凭据节点写的是小写的telerik,二者不匹配导致凭据完全没有被加载。将配置中<telerik>和</telerik>修改为<Telerik Nuget>和</Telerik Nuget>即可,修正后的凭据段示例:<packageSourceCredentials> <Telerik Nuget> <add key="Username" value="Telerik账户绑定邮箱" /> <add key="ClearTextPassword" value="Telerik账户密码或专用NuGet密钥" /> </Telerik Nuget> </packageSourceCredentials> - 确认使用的凭据有效性
Telerik NuGet源不支持微软账户、AD域账户直接认证,如果是用第三方账号关联登录Telerik,需要先到Telerik账户后台生成专用的NuGet API Key作为密码使用,不要直接填写第三方账号的登录密码。 - 清理本地NuGet缓存后重试
配置修改完成后,执行以下命令清理本地所有NuGet缓存,再重新执行包还原操作:dotnet nuget locals all --clear - 修正凭据管理器中存储的地址
手动在Windows凭据管理器添加的是v2版本源地址https://nuget.telerik.com/nuget,和配置中使用的v3地址https://nuget.telerik.com/v3/index.json不匹配,需要将凭据对应的地址修改为v3源地址,或者直接删除手动添加的凭据,避免多份配置冲突。
注意:修改配置后请完全关闭Visual Studio再重新打开解决方案,避免旧配置缓存导致修改不生效。
内容的提问来源于stack exchange,提问作者Arvind Chourasiya
相关产品推荐
相关产品推荐

