Git Product home page Git Product logo

fattureincloud-js-sdk's People

Contributors

emajo avatar fattureincloud-bot avatar stefanozanini avatar valmoz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fattureincloud-js-sdk's Issues

refreshToken of OAuth2AuthorizationCodeManager doesn't work properly

Describe the bug
The OAuth2AuthorizationCodeTokenResponse class returns undefined for all properties (tokenType, accessToken, redirectUri, expiresIn, refreshToken) when calling the refreshToken method of OAuth2AuthorizationCodeManager.

Env info

  • Node version: v20.11.0
  • JS SDK version: 2.0.17

To Reproduce
Utilize the refreshToken method within OAuth2AuthorizationCodeManager to refresh an access token. The method does not await the asynchronous call properly, leading to the issue.

var tokenObj = await oauth.refreshToken(json["refresh_token"]); console.log(tokenObj)
Produce this:
OAuth2AuthorizationCodeTokenResponse { tokenType: undefined, accessToken: undefined, redirectUri: undefined, expiresIn: undefined, refreshToken: undefined }

Expected behavior
refreshToken should return an instance of OAuth2AuthorizationCodeTokenResponse with all fields populated based on the API response.

Additional context
The issue seems to stem from not handling the promise returned by tokenRequest correctly in refreshToken. Proper promise resolution or async/await usage could fix this.
The portion of code that produce the error in the sdk:

refreshToken(refreshToken) {
  const tokenUri = `${this.baseUri}/oauth/token`;

  const data = {
    grant_type: 'refresh_token',
    client_id: this.clientId,
    client_secret: this.clientSecret,
    refresh_token: refreshToken
  };

  // Directly returning the promise without waiting for its resolution
  const res = this.tokenRequest(tokenUri, data);
  return new OAuth2AuthorizationCodeTokenResponse(res.token_type, res.access_token, res.refresh_token, res.expires_in);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.