未经授权的错误 401 在 Angular 中获取用于贝宝的 OAUTH2 令牌
Unauthorized Error 401 Get OAUTH2 Token for paypal in Angular
我正在处理 paypal 定期付款,我需要令牌来获取订阅者信息以允许其登录。但是我得到了未经授权的错误。这是我的代码
getTokan():Observable<any>{
let client_id = '411820721167-jcuj1jeae0l1j06i3q2otsnol2phlqem.apps.googleusercontent.com';
let secret = 'pe7berpzDSlwDVpgj-NQvseP';
let key = client_id+':'+secret;
let headers = new HttpHeaders({
"Accept": "application/json",
"Accept-Language": "en_US",
'Authorization': 'Basic '+key,
'Content-Type': 'application/x-www-form-urlencoded',
});
let options = { headers: headers };
return this.http.post<any>('https://api.sandbox.paypal.com/v1/oauth2/token',"grant_type=client_credentials", { headers: headers })
}
请解释一下什么是客户端 ID 和密码。我正在使用沙盒客户端 ID 秘密。我收到这个错误。
zone-evergreen.js:2845 POST https://api.sandbox.paypal.com/v1/oauth2/token 401(未授权)
这不是 PayPal REST APP 的 clientId 和密码。从 https://www.paypal.com/signin?intent=developer&returnUri=https%3A%2F%2Fdeveloper.paypal.com%2Fdeveloper%2Fapplications
的沙盒选项卡获取一对
此外,它们必须在您的请求中进行 Base64 编码
我正在处理 paypal 定期付款,我需要令牌来获取订阅者信息以允许其登录。但是我得到了未经授权的错误。这是我的代码
getTokan():Observable<any>{
let client_id = '411820721167-jcuj1jeae0l1j06i3q2otsnol2phlqem.apps.googleusercontent.com';
let secret = 'pe7berpzDSlwDVpgj-NQvseP';
let key = client_id+':'+secret;
let headers = new HttpHeaders({
"Accept": "application/json",
"Accept-Language": "en_US",
'Authorization': 'Basic '+key,
'Content-Type': 'application/x-www-form-urlencoded',
});
let options = { headers: headers };
return this.http.post<any>('https://api.sandbox.paypal.com/v1/oauth2/token',"grant_type=client_credentials", { headers: headers })
}
请解释一下什么是客户端 ID 和密码。我正在使用沙盒客户端 ID 秘密。我收到这个错误。
zone-evergreen.js:2845 POST https://api.sandbox.paypal.com/v1/oauth2/token 401(未授权)
这不是 PayPal REST APP 的 clientId 和密码。从 https://www.paypal.com/signin?intent=developer&returnUri=https%3A%2F%2Fdeveloper.paypal.com%2Fdeveloper%2Fapplications
的沙盒选项卡获取一对此外,它们必须在您的请求中进行 Base64 编码