Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GetToken(){
- data.username = document.getElementById('usernameInput').value;
- data.password = document.getElementById('passwordInput').value;
- console.log(data.username);
- console.log(data.password);
- //const uri = `oauth/token?grant_type=password&username=${data.username}&password=${data.password}`;
- const uri = `oauth/token?grant_type=password&username=${data.username}&password=${data.password}`;
- console.log(uri);
- fetch(uri, {
- headers: {
- 'Host' : 'localhost:8090',
- 'Content-Type': 'application/x-www-form-urlencoded',
- 'authorization' : "Basic " + base64.encode("my-trusted-client:secret")
- },
- method : 'POST'
- }).then((response) => {
- return response.json()})
- .then((json) => {
- Cookies.set('access_token', json.access_token, {expires: 7});
- })
- .then (() => this.GetRole());
- //console.log(sessionStorage.getItem('webtoken'))
- console.log(Cookies.get('access_token'));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement