microsoft-graph-toolkit icon indicating copy to clipboard operation
microsoft-graph-toolkit copied to clipboard

[BUG] Issue with the Login component using the ElectronProvider

Open diptanu143 opened this issue 2 years ago • 7 comments

Describe the bug While using the ElectronProvider using the sample repo for typescript electron boilerplate, I get an error as below. Attaching some screenshots as well for reference. Appreciate some help on understanding what is going wrong.

My app registration is quite simple as per the steps explained here - https://docs.microsoft.com/en-us/graph/toolkit/providers/electron

Error in execution - Error occurred in handler for 'login': ClientAuthError: request_cannot_be_made: Token request cannot be made without authorization code or refresh token. at ClientAuthError.AuthError [as constructor] (webpack://electron-app-mgt/./node_modules/@azure/msal-common/dist/error/AuthError.js?:34:24) at new ClientAuthError (webpack://electron-app-mgt/./node_modules/@azure/msal-common/dist/error/ClientAuthError.js?:209:28) at Function.ClientAuthError.createTokenRequestCannotBeMadeError (webpack://electron-app-mgt/./node_modules/@azure/msal-common/dist/error/ClientAuthError.js?:322:16) at AuthorizationCodeClient.eval (webpack://electron-app-mgt/./node_modules/@azure/msal-common/dist/client/AuthorizationCodeClient.js?:83:106) at step (webpack://electron-app-mgt/./node_modules/@azure/msal-common/dist/_virtual/_tslib.js?:83:23) at Object.eval [as next] (webpack://electron-app-mgt/./node_modules/@azure/msal-common/dist/_virtual/_tslib.js?:64:53) at eval (webpack://electron-app-mgt/./node_modules/@azure/msal-common/dist/_virtual/_tslib.js?:57:71) at new Promise () at __awaiter (webpack://electron-app-mgt/./node_modules/@azure/msal-common/dist/_virtual/_tslib.js?:53:12) at AuthorizationCodeClient.acquireToken (webpack://electron-app-mgt/./node_modules/@azure/msal-common/dist/client/AuthorizationCodeClient.js?:76:76) { errorCode: 'request_cannot_be_made', errorMessage: 'Token request cannot be made without authorization code or refresh token.', subError: '' }

App registration image

diptanu143 avatar Apr 13 '22 06:04 diptanu143

Hello diptanu143, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

ghost avatar Apr 13 '22 06:04 ghost

@musale where is the solution in #1648 ?

diptanu143 avatar Apr 25 '22 08:04 diptanu143

@musale where is the solution in #1648 ?

Still triaging. The solution for this should also fix #1648. Are they different according to you?

musale avatar Apr 25 '22 09:04 musale

no they are same but I see both the issues are closed.. Hence worried..

diptanu143 avatar Apr 25 '22 09:04 diptanu143

no they are same but I see both the issues are closed.. Hence worried..

This one is open :) I can't reproduce your bug @diptanu143. Do you have an idea which component throws the error during rendering? You can comment out each of the sample components in the <body> tag. Then uncomment one by one. I want to know what calls are being made that throw the error.

musale avatar Apr 25 '22 11:04 musale

I can repro this!

node:electron/js2c/renderer_init:57 Uncaught (in promise) Error: Error invoking remote method 'login': ClientAuthError: request_cannot_be_made: Token request cannot be made without authorization code or refresh token. at EventEmitter.o.invoke (node:electron/js2c/renderer_init:57:526)

the component is Login from '@microsoft/mgt-react';

danieljaguiar avatar May 02 '22 22:05 danieljaguiar

I have 2 tenants, one with MFA and other without.

@diptanu143 , I could fix in the tenant without MFA by adding the authority to MsalElectronConfig:

const config: MsalElectronConfig = {
    clientId: 'xxxxx', // xxxx = Application ID (UUID)
    mainWindow: newWindow,
    authority: 'https://login.microsoftonline.com/yyy', // yyy = Tenant UUID
    scopes: ['user.read'],
  };

@musale For my Tenant with MFA enabled, this is still a mystery!

danieljaguiar avatar May 02 '22 23:05 danieljaguiar

@danieljaguiar - i dont have MFA but it still doesnt work

diptanu143 avatar Feb 27 '23 11:02 diptanu143

@diptanu143 @danieljaguiar sorry for the late update. We have released v3.0.0 now and you can test and see if this issue is still happening.

musale avatar Jun 29 '23 10:06 musale

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@musale Unfortunately, I still get an error but a different one now -

image

image

diptanu143 avatar Jul 24 '23 10:07 diptanu143

@diptanu143 what provider are you using? It's recommended to use Msal2Provider.

musale avatar Jul 24 '23 16:07 musale

Enhancements are happening with v4, including a new Electron Provider! You can test if by installing our @next packages! Closing this issue for now but feel free to reach out if you have any questions and re-open it!

sebastienlevert avatar Jan 30 '24 03:01 sebastienlevert