2015-06-27 55 views

回答

1

我終於設法解決了它。我根據我的回答從icodeya

function authenticateUser(username, authtoken) { 

    var url = "https://api.github.com/user" 

    var credentials = btoa(username + ':' + authtoken); 
    var authorization = {'Authorization': 'Basic ' + credentials}; 
    var header = { headers: authorization } 

    return $http.get(url, header) 
    .then(function(response) { 
     function() { //do something here. } 
    } 
); 
} 
+0

就是這麼做的!我很好奇你使用的令牌,它是一個智威湯遜?你在哪裏存儲它?我總是希望幫助前端安全:)如果您正在構建前端應用程序,您可能會發現我的博客文章很有用: [單頁面應用程序的基於令牌的身份驗證](https:// stormpath.com/blog/build-secure-user-interfaces-using-jwts/) [https://stormpath.com/blog/build-secure-user-interfaces-using-jwts/](https:// stormpath.com/blog/token-auth-spa/) – robertjd

相關問題