PHP:如何在GET/POST调用中将承载令牌传递给Azure API?
我打电话到PHP:如何在GET/POST调用中将承载令牌传递给Azure API?,php,azure,active-directory,http-headers,access-token,Php,Azure,Active Directory,Http Headers,Access Token,我打电话到https://login.windows.net/common/oauth2/token并收到类似的回复: { "token_type": "Bearer", "scope": "Directory.Read.All User.Read", "expires_in": "3600", "ext_expires_in": "0", "resource": "https://graph.windows.net", "access_token
https://login.windows.net/common/oauth2/token
并收到类似的回复:
{
"token_type": "Bearer",
"scope": "Directory.Read.All User.Read",
"expires_in": "3600",
"ext_expires_in": "0",
"resource": "https://graph.windows.net",
"access_token": {{really_long_token_1}},
"refresh_token": {{really_long_token_2}},
"id_token": {{really_long_token_3}}
}
我有一个托管在HostGator上的网站,它试图访问我在Azure上找到的API
对Azure上托管的my API的GET
调用的正确形式是什么?以下是我目前掌握的情况:
$url = 'https://myappservice.azurewebsites.net/api/getValues';
$options = array(
'http' => array(
'header' => array(
'x-ms-version: 2017-06-02',
'Authorization: Bearer {{really_long_token_1}}'
),
'method' => 'GET'
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
$var_dump($result);
我在进行此呼叫时,最终收到
500
服务器错误。此500
为内部错误,表示服务器遇到意外情况,无法满足请求
它不应与身份验证/授权相关,请检查是否存在导致此异常的代码。或者,您可以使用非常简单的代码示例替换代码,而不需要任何复杂的业务逻辑,只需返回值即可