当我将内容类型标头设置为application/json
,将Authorization
标头设置为精确值 {{ 1}}通过邮递员可以很好地响应预期的响应,但是当我尝试通过Bearer SampleToken
设置请求授权标头时,它会给我一个响应
URLRequest
当我通过查尔斯监视请求时,我注意到{
error = "access_denied";
"error_description" = "OAuth2 authentication required";
}
标头被剥夺了。我尝试了多种方法来设置授权标头,但没有运气。
Authorization
原始邮递员请求:
答案 0 :(得分:0)
尝试更改
request.setValue("Bearer SampleToken", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
到
request.allHTTPHeaderFields = [
"Authorization": "Bearer SampleToken",
"Content-Type": "application/json"
]
答案 1 :(得分:0)
您的授权令牌应为<b-form-input id="nestedCategory" v-model="productCategory" :value="category.name readonly/>
的base64编码的字符串
user:password