Advertisement
Guest User

Untitled

a guest
May 9th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. GetToken(){
  2. data.username = document.getElementById('usernameInput').value;
  3. data.password = document.getElementById('passwordInput').value;
  4.  
  5. console.log(data.username);
  6. console.log(data.password);
  7. //const uri = `oauth/token?grant_type=password&username=${data.username}&password=${data.password}`;
  8. const uri = `oauth/token?grant_type=password&username=${data.username}&password=${data.password}`;
  9. console.log(uri);
  10. fetch(uri, {
  11. headers: {
  12. 'Host' : 'localhost:8090',
  13. 'Content-Type': 'application/x-www-form-urlencoded',
  14. 'authorization' : "Basic " + base64.encode("my-trusted-client:secret")
  15. },
  16. method : 'POST'
  17. }).then((response) => {
  18. return response.json()})
  19. .then((json) => {
  20. Cookies.set('access_token', json.access_token, {expires: 7});
  21. })
  22. .then (() => this.GetRole());
  23. //console.log(sessionStorage.getItem('webtoken'))
  24. console.log(Cookies.get('access_token'));
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement