@@ -39,50 +39,41 @@ type OAuthResponse struct {
3939
4040// getNewToken updates the held token and expiry information
4141func (a * oauth ) getNewToken () error {
42- a .Sugar .Warn ("THREE-TWO-ONE" )
4342 data := url.Values {}
4443 data .Set ("client_id" , a .clientId )
4544 data .Set ("client_secret" , a .clientSecret )
4645 data .Set ("grant_type" , "client_credentials" )
4746
48- a .Sugar .Warn ("THREE-TWO-TWO" )
4947 oauthComlpeteEndpoint := a .baseDomain + oAuthTokenEndpoint
5048 a .Sugar .Debugf ("oauth endpoint constructed: %s" , oauthComlpeteEndpoint )
5149
52- a .Sugar .Warn ("THREE-TWO-THREE" )
5350 req , err := http .NewRequest ("POST" , oauthComlpeteEndpoint , strings .NewReader (data .Encode ()))
5451 if err != nil {
5552 return err
5653 }
57- a .Sugar .Warn ("THREE-TWO-FOUR" )
5854
5955 a .Sugar .Debugf ("oauth token request constructed: %+v" , req )
6056
6157 req .Header .Add ("Content-Type" , "application/x-www-form-urlencoded" )
6258
63- a .Sugar .Warn ("THREE-TWO-FIVE" )
6459 resp , err := a .httpExecutor .Do (req )
6560 if err != nil {
6661 return err
6762 }
68- a .Sugar .Warn ("THREE-TWO-SIX" )
6963
7064 if resp .StatusCode < 200 || resp .StatusCode > 299 {
7165 return fmt .Errorf ("bad request getting auth token: %v" , resp )
7266 }
7367
7468 defer resp .Body .Close ()
7569
76- a .Sugar .Warn ("THREE-TWO-SEVEN" )
7770 bodyBytes , err := io .ReadAll (resp .Body )
7871 if err != nil {
7972 return err
8073 }
81- a .Sugar .Warn ("THREE-TWO-EIGHT" )
8274
8375 resp .Body = io .NopCloser (bytes .NewBuffer (bodyBytes ))
8476
85- a .Sugar .Warn ("THREE-TWO-NINE" )
8677 oauthResp := & OAuthResponse {}
8778 err = json .Unmarshal (bodyBytes , oauthResp )
8879 if err != nil {
0 commit comments