Merge pull request #28 from reefqi037/add-bearer-token-auth

Added token based authentication type

Co-authored-by: rifqi <rifqi.alabqary@gmail.com>
This commit is contained in:
Liyas Thomas
2019-08-23 12:57:54 +05:30
committed by GitHub
2 changed files with 11 additions and 0 deletions

View File

@@ -18,6 +18,7 @@ const app = new Vue({
path: '/api',
httpUser: '',
httpPassword: '',
bearerToken: '',
params: [],
bodyParams: [],
contentType: 'application/json',
@@ -129,6 +130,9 @@ const app = new Vue({
const user = this.auth === 'Basic' ? this.httpUser : null
const pswd = this.auth === 'Basic' ? this.httpPassword : null
xhr.open(this.method, this.url + this.path + this.queryString, true, user, pswd)
if (this.auth === 'Bearer Token') {
xhr.setRequestHeader('Authorization', 'Bearer ' + this.bearerToken);
}
if (this.method === 'POST' || this.method === 'PUT') {
const requestBody = this.rawRequestBody
xhr.setRequestHeader('Content-Length', requestBody.length)