fattureincloud / fattureincloud-js-sdk Goto Github PK
View Code? Open in Web Editor NEWFatture in Cloud SDK (Software Development Kit) for JavaScript
Home Page: https://www.fattureincloud.it
License: MIT License
Fatture in Cloud SDK (Software Development Kit) for JavaScript
Home Page: https://www.fattureincloud.it
License: MIT License
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
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);
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.