2016-11-20 4 views
0

AWS API 게이트웨이와 AWS Cognito User 풀을 통합했습니다. 다음 컬 명령이 작동합니다.AWS API 게이트웨이 인증 실패

그러나 인증은 다음 Angulesjs $ http.put으로 실패합니다. AWS의 CloudWatch는 로그

$http.defaults.headers.common['Authorization'] = token 
$http.put('https://<url>', <json data>) 
    .then(function (data, status, headers, config) { 
     console.log('success') 
    }, function (data, status, headers, config) { 
     console.log('failure') 
    }); 

어떻게

이 인증 토큰은 $ http.put로 설정해야합니다 "사용자가 인증되지 않은 것입니다"보여?

답변

0

내가 원하는 것은 $http.put(<url>, options)...의 두 번째 인수로 요청 헤더를 설정하는 것입니다.

그래서 귀하의 경우, 코드는 다음과 같이한다 : 당신은 $http.X 메소드를 호출하는 다른 방법에 대한 자세한 내용은 documentation here을 확인할 수 있습니다

var options = {headers: { 
         'Authorization': token, 
         'Content-Type': 'application/json' 
         } 
       }; 

$http.put('https://<url>', <json data>, options); 

.

이 정보가 도움이되기를 바랍니다.

관련 문제