2016-05-16 37 views
0

当访问jhipster的oauth2 API在我离子应用但我没有得到响应。这是$ HTTP请求我从我的应用程序离子发送访问jhipster的oauth2离子应用验证REST API

$http({ 
    method: "post", 
    url: "http://192.168.0.5:8080/auth-2-sconnect/oauth/token", 
    data: "username=admin&password=admin&grant_type=password&scope=read write&client_secret=my-secret-token-to-change-in-production&client_id=auth2Sconnectapp", 
    withCredentials: true, 
    headers: { 
     'Accept':'application/json', 
     'Content-Type': 'application/x-www-form-urlencoded' 
     } 
    })     
    .success(function(data) { 
     alert("success: " + data); 
    }) 
    .error(function(data, status) { 
     alert("ERROR: " + data); 
    }); 

这也给** Status Code:403 Forbidden**错误,如果我插入

'Authorization': 'Basic ' + 'YXV0aDJTY29ubmVjdGFwcDpteS1zZWNyZXQtdG9rZW4tdG8tY2hhbmdlLWluLXByb2R1Y3Rpb24=' 

+0

您是否检查代理? – mattymanme

+1

JYSTER应用程序和离子应用程序都在我的本地机器上运行 – abhi314

+0

您是否尝试使用此URL? 'url:“http:// localhost:8080/auth-2-sconnect/oauth/token”,' – mattymanme

回答

0

我这不同于jsyter应用程序的application.yml中的CORS评论说,这似乎是诀窍。

我的离子应用程序现在工作正常。