[英]How to include the sope datas to generate an access token Oauth2.0?
I need to generate an access token Oauth2.0 to call a webservice. 我需要生成访问令牌Oauth2.0才能调用Web服务。
My PHP script return an access token but when i call the webservice with this token i have an error code 115 (OAuth access token is not valid). 我的PHP脚本返回访问令牌,但是当我使用此令牌调用Web服务时,我收到错误代码115(OAuth访问令牌无效)。
$client_id = 'XXXXX';
$client_secret = 'XXXXX';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'XXXXX/auth/oauth/v2/token' );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, 'grant_type=client_credentials');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Basic '.base64_encode($client_id.':'.$client_secret)));
$res = curl_exec($ch);
I tried with postman to generate an access token with the same datas such as my PHP script i have the same error code (115) but when i add the scope datas, the access token generate is now valid to call the webservice. 我尝试与邮递员生成具有相同数据的访问令牌,例如我的PHP脚本,我具有相同的错误代码(115),但是当我添加范围数据时,生成的访问令牌现在可以调用Web服务了。
Do you know how to include the scope datas on my PHP script ? 您知道如何在我的PHP脚本中包含范围数据吗?
Provide a scope request parameter whose value is set a form-encoded list of requested scopes separated by spaces. 提供一个范围请求参数,其值设置为一个用空格分隔的请求范围的形式编码列表。 Eg to request read
and write
scopes you'd use: 例如要求read
和write
你使用范围:
curl_setopt($ch, CURLOPT_POSTFIELDS, 'scope=read%20write');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.