I need to generate an access token Oauth2.0 to call a webservice.
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).
$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.
Do you know how to include the scope datas on my PHP script ?
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:
curl_setopt($ch, CURLOPT_POSTFIELDS, 'scope=read%20write');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.