我正在编写一个Web应用程序,它将访问存储在Microsoft Dynamics CRM Online中的客户端数据。我希望允许我的用户使用OAuth授予对其Dynamics帐户的访问权限。
我无法将此“代码”替换为“access_token”。
$data = array(
"grant_type" => "authorization_code",
"client_id" => urlencode("my_app_azure_ad_client_id"),
"redirect_uri" => urlencode("https://myapp.com/callback"),
"client_secret" => urlencode("my_app_azure_ad_client_secret"),
"code" => urlencode("code_returned_from_previous_request"),
"resource" => urlencode("https://examplecrmaccount4.crm4.dynamics.com")
);
$endpoint = "https://login.windows.net/common/oauth2/token?api-version=1.0";
$response = helpers\Curl::doPOST(
$endpoint,
null,
array("Content-type: application/x-www-form-urlencoded"),
$data
);
服务器响应:
Status 404
StatusName Not Found
{"error":"invalid_request","error_description":"ACS90002: No service namespace named \u0027common\u0027 was found in the data store.\r\nTrace ID: b1025082-3e9b-49d8-bf91-7d998f694162\r\nCorrelation ID: 49d9d1e5-6958-4ffc-91ff-464f078a00f5\r\nTimestamp: 2014-09-12 08:35:59Z","error_codes":[90002],"timestamp":"2014-09-12 08:35:59Z","trace_id":"b1025082-3e9b-49d8-bf91-7d998f694162","correlation_id":"49d9d1e5-6958-4ffc-91ff-464f078a00f5"}
答案 0 :(得分:2)
删除“api-version = 1.0”查询参数,它应该可以工作。这是我们的文档和Azure门户中的一个错误,它告诉您在使用授权代码流时添加它。