2015-06-27 50 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

相关问题