@@ -886,8 +886,11 @@ func GetProjectStatus(sonarHost string, analysisId string) ([]byte, error) {
886886
887887 fmt .Printf ("\n " )
888888 // fmt.Printf("Setting Authorization header:" + token)
889+ // Retry with the token encoded in base64
890+ encodedToken := base64 .StdEncoding .EncodeToString ([]byte (token ))
891+ projectRequest .Header .Set ("Authorization" , "Basic " + encodedToken )
889892
890- projectRequest .Header .Add ("Authorization" , "Basic " + token )
893+ // projectRequest.Header.Add("Authorization", "Basic "+token)
891894 projectResponse , err := netClient .Do (projectRequest )
892895
893896 if err != nil {
@@ -912,13 +915,14 @@ func GetProjectStatus(sonarHost string, analysisId string) ([]byte, error) {
912915 projectBearerResponse , err := netClient .Do (projectBearerRequest )
913916 if err != nil {
914917 fmt .Printf ("\n " )
915- fmt .Printf ("Error getting project status, trying again with bearer token..." )
918+ fmt .Printf ("NIL - Error getting project status, trying again with bearer token..." )
916919 return nil , err
917920 }
918921 fmt .Printf ("Response Code with Bearer:" + projectBearerResponse .Status )
919922 if projectBearerResponse .StatusCode == 401 {
920923 fmt .Printf ("\n " )
921924 fmt .Printf ("Error getting project status, trying again with bearer token..." )
925+
922926 return nil , fmt .Errorf ("unauthorized to get project status" )
923927 }
924928 bufResponse , err := ioutil .ReadAll (projectBearerResponse .Body )
@@ -980,6 +984,8 @@ func GetLatestTaskID(sonarHost string, projectSlug string) (string, error) {
980984 fmt .Printf ("Retrying with encoded token...\n " )
981985
982986 encodedToken := base64 .StdEncoding .EncodeToString ([]byte (sonarToken ))
987+ req .Header .Add ("Authorization" , "Basic " + encodedToken )
988+ fmt .Printf ("Token encoded: %s\n " , encodedToken )
983989 req .SetBasicAuth (encodedToken , "" )
984990 resp , err = netClient .Do (req )
985991 if err != nil {
0 commit comments