我在Angular 4中編寫了一個調用REST API(DJANGO)的應用程序。 的代碼如下:Angular 4 GET 403響應
export class ForecastUnitService {
private path = 'forecastunit/';
private options;
constructor (private http: Http, private c:CentralService) {
this.options=this.c.createOptions();
}
getForecastUnits(): Observable<ForecastUnit[]> {
return this.http.get(this.c.createURL(this.path),this.options)
.map(this.extractData)
.catch(this.handleError);
}
...
}
我補充一點,包含授權頭的選擇,但我仍然得到 403禁止。然而,當我用cUrl或郵差嘗試打電話時,或者在招搖時,同樣的道理,我會得到結果。 所以第一因子評分,標題是不正確的,但是當我登錄的選項,我得到:
{"method":null,"headers":{"Authorization":["**Correct Token**"],"Content-Type":["application/json"]},"body":null,"url":null,"withCredentials":null,"responseType":null}
所以這是沒有問題的,當我看着從Chrome中的迴應,我看到以下內容:
{"detail":"Authentication credentials were not provided."}
所以再次沒有憑據,但我真的通過他們,出了什麼問題?
什麼是您傳遞的令牌的格式? – Aniket
基本64,我猜 – fangio
想知道你傳遞的令牌的示例格式 – Aniket