From 9cc9d9088a78f100308e1086e968908dd0299815 Mon Sep 17 00:00:00 2001 From: Dario Nascimento Date: Thu, 29 Sep 2022 12:21:42 +1000 Subject: [PATCH] Add support for Token authentication --- server/server.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/server.go b/server/server.go index 8ea18ac..624cb2d 100644 --- a/server/server.go +++ b/server/server.go @@ -24,7 +24,7 @@ const ( // UserCredential holds the username and password that the API should use to // authenticate to the REST API type UserCredential struct { - Domain, Username, Password string + Domain, Username, Password, Token string } // Configuration settings for the API @@ -254,6 +254,9 @@ func (s Server) uploadFile(secretId int, fileField SecretField) error { // getAccessToken gets an OAuth2 Access Grant and returns the token // endpoint and get an accessGrant. func (s Server) getAccessToken() (string, error) { + if s.Credentials.Token != "" { + return s.Credentials.Token, nil + } values := url.Values{ "username": {s.Credentials.Username}, "password": {s.Credentials.Password},