我需要帮助来解决这个问题。在执行POST请求以获取IOS中的访问令牌时,我面临问题。而它在Android系统中运行得很好。
我正在使用Cordova插件cordova-plugin-advanced-http: "^2.4.1"。
代码:
const bodyParams = {‘client_id’:clientId,‘client_secret’:secret,‘grant_type’:‘authorization_code’,‘code’:tokenOrCode};
const httpResponse = await this.http.post(accessTokenUrl, bodyParams, {“Content-Type”: “application/json”});错误:
{“error”:“invalid_client”,“error_description”:“FBTOAU204E An invalid secret was provided for the client with identifier: ‘abc@abc.com’.”}注意:上面的代码在中工作,没有任何问题。
Package.json:
"@angular/common": "^7.2.2",
"@angular/core": "^7.2.2",
"@angular/forms": "^7.2.2",
"@angular/http": "^7.2.2",
"@angular/platform-browser": "^7.2.2",
"@angular/platform-browser-dynamic": "^7.2.2",
"@angular/router": "^7.2.2",
"@ionic-native/core": "^5.0.0",
"@ionic-native/http": "^5.2.0",
"@ionic-native/network": "^5.24.0",
"@ionic-native/secure-storage": "^5.2.0",
"@ionic-native/splash-screen": "^5.0.0",
"@ionic-native/status-bar": "^5.0.0",
"@ionic/angular": "^4.1.0",
"ajv": "^6.10.0",
"cordova-ios": "^4.5.5",
"cordova-plugin-advanced-http": "^2.0.9",
"cordova-plugin-cookiemaster": "^1.0.5",
"cordova-plugin-device": "^2.0.3",
"cordova-plugin-file": "^6.0.2",
"cordova-plugin-ionic-keyboard": "^2.2.0",
"cordova-plugin-ionic-webview": "^3.0.0",
"cordova-plugin-network-information": "^2.0.2",
"cordova-plugin-secure-storage": "^3.0.2",
"cordova-plugin-splashscreen": "^5.0.3",
"cordova-plugin-statusbar": "^2.4.3",
"cordova-plugin-whitelist": "^1.3.4",
"core-js": "^2.5.4",
"rxjs": "~6.3.3",
"zone.js": "~0.8.29"发布于 2020-04-22 06:11:43
在发送post请求之前,请按照请求设置序列化程序:
对于json:
this.http.setDataSerializer("json");
const bodyParams = {‘client_id’:clientId,‘client_secret’:secret,‘grant_type’:‘authorization_code’,‘code’:tokenOrCode};
const httpResponse = await this.http.post(accessTokenUrl, bodyParams, {“Content-Type”: “application/json”});发布于 2021-03-25 08:48:44
我遇到了一个与你的问题类似的问题,比如request在Android上工作,而不是在Ios上工作。(离子5-电容器应用程序)
我解决了我的问题,改变了我的内容类型。
它也可能对你有帮助,请试试。
{“Content-Type”: “application/json”}将以下内容替换为
{“Content-Type”: “application/x-www-form-urlencoded”}https://stackoverflow.com/questions/61352800
复制相似问题