2017-12-27 8 views
0

나는 아약스가 말려 들길 원한다.아약스로 컬 컬링 -> curl localhost : 8080/oauth/token -h foo : bar -d grant_type = 패스워드 -d username = [email protected] -d 패스워드 = 1

컬 로컬 호스트 : 8080/OAuth를/토큰 -h foo는 : 바 -d grant_type = 비밀번호 -d [email protected] -d 암호 = 위의 명령이 성공 1

.

하지만 아약스 실패는 ...

$.ajax({ 
    url: 'http://localhost:8080/oauth/token', 
    type: 'POST', 
    dataType: 'json', 
    contentType: 'application/x-www-form-urlencoded; charset=UTF-8', 
    beforeSend: function (xhr) { 
     xhr.setRequestHeader('Authorization', 'Basic' + btoa('foo:bar')); 

    }, 
    data: { 
     grant_type: 'password', 
     username: '[email protected]', 
     password: '1' 
    }, 
    complete: function(result) { 
     console.log('complete', result); 
    }, 

    success: function(result) { 
     console.log('success', result); 
    }, 

    error: function(result) { 
     console.log('error', result); 
    } 
}); 

나는 아약스로 변환하고 다음과 같은 오류가 나타납니다. 프리 플라이트에 대한

응답 유효하지 않은 HTTP 상태 코드를 가지고 401

responseJSON :

문제가 무엇입니까

정의되지?

답변

0

해결책을 찾았습니다.

수정 OauthServer

변경 "source.registerCorsConfiguration ("/ ** ", configAutenticacao);" ""source.registerCorsConfiguration ("/ oauth/token", configAutenticacao); " in corsFilterRegistrationBean