我有一个Azure广告B2C。由于Azure Active Directory已迁移到新门户,我在使用Azure Graph API读取和写入租户用户数据时遇到了问题。以前,我有一个应用程序是从旧门户创建的,现在无法使用。
因此,我从新门户创建了一个新的应用程序,如下所示:
-
打开“Azure Active Directory”选项卡
-
-
点击“新申请注册”
-
-
“回复URL”选项卡包含:
-
https://graph。窗户。net/winbizdev。onmicrosoft。通用域名格式
-
-
Windows Azure Active Directory->检查3个不需要管理员的元素
-
“关键点”选项卡包括:
下面是我从Azure Graph API访问用户数据的C代码:
_authContext = new AuthenticationContext("https://login.microsoftonline.com/myTenant.onmicrosoft.com");
_credential = new ClientCredential("<Application Client Guid>", "<Client secret which I created in "Keys" tab");
var result = await _authContext.AcquireTokenAsync("https://graph.windows.net/", _credential);
var http = new HttpClient();
var graphUrl = "https://graph.windows.net/myTenant.onmicrosoft.com/users/<My User Guid>?api-version=1.6";
var request = new HttpRequestMessage(new HttpMethod("GET"), graphUrl);
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", result.AccessToken);
var response = await http.SendAsync(request);
return response;
我总是得到一个403错误禁止。程序集“Microsoft.IdentityModel.Clients.ActiveDirectory”的版本为3.13.8.99。
谢谢你的帮助!
亚历克斯