@@ -176,7 +176,7 @@ func (c *APIClient) prepareRequest (
176176
177177 // set custom header
178178 headerParams ["x-aspose-client" ] = "go sdk"
179- headerParams ["x-aspose-client-version" ] = "22.7 .0"
179+ headerParams ["x-aspose-client-version" ] = "22.8 .0"
180180
181181 // Detect postBody type and post.
182182 if postBody != nil {
@@ -420,24 +420,30 @@ func (a *APIClient) addAuth(request *http.Request) (err error) {
420420}
421421
422422// RequestOauthToken function for requests OAuth token
423- func (a * APIClient ) RequestOauthToken () (error ) {
424-
425- resp , err := http .PostForm (strings .Replace (a .cfg .BasePath , "/v3.0" , "/connect/token" , - 1 ), url.Values {
426- "grant_type" : {"client_credentials" },
427- "client_id" : {a .cfg .AppSid },
428- "client_secret" : {a .cfg .AppKey }})
429-
430- if err != nil {
431- return err
432- }
433- defer resp .Body .Close ()
434-
435- var tr TokenResp
436- if err = json .NewDecoder (resp .Body ).Decode (& tr ); err != nil {
437- return err
438- }
439- a .cfg .AccessToken = tr .AccessToken
440- return nil
423+ func (a * APIClient ) RequestOauthToken () error {
424+ resp , err := http .PostForm (
425+ strings .Replace (a .cfg .BasePath , "/v3.0" , "/connect/token" , - 1 ),
426+ // a.cfg.BasePath+"/pdf/connect/token",
427+ url.Values {
428+ "grant_type" : {"client_credentials" },
429+ "client_id" : {a .cfg .AppSid },
430+ "client_secret" : {a .cfg .AppKey },
431+ },
432+ )
433+ if err != nil {
434+ return err
435+ }
436+ defer resp .Body .Close ()
437+ bodyBytes , _ := io .ReadAll (resp .Body )
438+ var tr TokenResp
439+ if err = json .NewDecoder (bytes .NewReader (bodyBytes )).Decode (& tr ); err != nil {
440+ return fmt .Errorf ("%s (wrapped error: %w)" , bodyBytes , err )
441+ }
442+ if len (tr .AccessToken ) == 0 {
443+ return fmt .Errorf ("empty token (%s)" , bodyBytes )
444+ }
445+ a .cfg .AccessToken = tr .AccessToken
446+ return nil
441447}
442448
443449func deserializeDTO (readCloser io.Reader , successPayload interface {}) error {
0 commit comments