Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate AccessTokenAdapter.toAuthorizationCallback(string) #279

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

karolis-zukauskas
Copy link

Depracate AccessTokenAdapter.toAuthorizationCallback(string) to be replaced with AccessTokenAdapter.toAuthorizationCallback(() => Promise<AccessToken>).

#278

public static toAuthorizationCallback(accessToken: AccessToken): AuthorizationCallback {
const authorization: Authorization = AccessTokenAdapter.toAuthorization(accessToken);
return async () => authorization;
/** @deprecated in 5.2. Use {@link toAuthorizationCallback} with a callback parameter instead. */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just deprecate the entire class?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class is meant to change from the iTwin.js token format to imodels-clients token format. I don't see a reason why it should be deprecated, even if the formats matched.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does the imodels-clients have their own format?
every other place in platform its a string, in fact you guys just construct a string from it, eg https://github.com/iTwin/imodels-clients/blob/main/clients/imodels-client-management/src/base/internal/OperationsBase.ts#L125

this class has been a constant source of issues for consumers, and there is no need for this to be a static, it can be a namespace with utility functions if needed

deprecating entire utility class is out of scope for this pr, but want to mention it as we are touching this file right now, and we can add it to the backlog

Copy link
Collaborator

@Animagne Animagne Dec 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imodels-clients packages are designed to work without iTwin.js. Any website that does not depend on a general purpose backend should be able to use these same clients (more imodels-clients-management), they cover full functionality of iModels APIs and allow any way of getting access token to be used.

We are reducing the impacted area when itwinjs-core is changing to this single adapter package. I cannot remember all of the arguments against passing token as a single string right now (likely concerns about extensibility and not being able to add additional properties). But the biggest issue that I can currently see from the code is IModelHost.getAccessToken returning empty string on failure. If imodels-clients didn't validate that the token at least appears valid, it would cause unnecessary noise on iModels API side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants