Continue Discussion 51 replies
June 2020

konrad.sopala Community Engineer

If you have any struggles or thoughts about the article let us know here in the thread!

1 reply
June 2020

mfeldman143

Tried three different ways…“Sign in with Google” freezes the electron app…Console shows: auth0.min.esm.js:8 Following parameters are not allowed on the /authorize endpoint: [is_submitting,sso]

Other errors: when logging in and title of the Electron said a russian word: Переадресация…

Other errors:

(node:6808) UnhandledPromiseRejectionWarning: Error: Request failed with status code 400
at createError (C:\NewFolders\electron-openid-oauth-master\electron-openid-oauthTry3\frontend\node_modules\axios\lib\core\createError.js:16:15)
at settle (C:\NewFolders\electron-openid-oauth-master\electron-openid-oauthTry3\frontend\node_modules\axios\lib\core\settle.js:17:12)
at IncomingMessage.handleStreamEnd (C:\NewFolders\electron-openid-oauth-master\electron-openid-oauthTry3\frontend\node_modules\axios\lib\adapters\http.js:236:11)
at IncomingMessage.emit (events.js:228:7)
at endReadableNT (_stream_readable.js:1185:12)
at processTicksAndRejections (internal/process/task_queues.js:81:21)
(node:6808) UnhandledPromiseRejectionWarning: Error: Request failed with status code 400
at createError (C:\NewFolders\electron-openid-oauth-master\electron-openid-oauthTry3\frontend\node_modules\axios\lib\core\createError.js:16:15)
at settle (C:\NewFolders\electron-openid-oauth-master\electron-openid-oauthTry3\frontend\node_modules\axios\lib\core\settle.js:17:12)
at IncomingMessage.handleStreamEnd (C:\NewFolders\electron-openid-oauth-master\electron-openid-oauthTry3\frontend\node_modules\axios\lib\adapters\http.js:236:11)
at IncomingMessage.emit (events.js:228:7)
at endReadableNT (_stream_readable.js:1185:12)
at processTicksAndRejections (internal/process/task_queues.js:81:21)
(node:6808) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing
inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:6808) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing
inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:6808) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:6808) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Trying Windows and the git repo as-is (Electron 9, followed all directions for Auth0 configs: apiIdentifier, auth0Domain, clientId)

1 reply
June 2020 ▶ mfeldman143

andrea.chiarelli Auth0 Employee

Hey @mfeldman143,
I’m not able to reproduce your issue. I need additional info to understand what is happening.

Please, provide me with this additional info. I will check it with our engineering team.
Thanks

1 reply
June 2020 ▶ andrea.chiarelli

mfeldman143

Thanks for quick reply!
I managed to get it working after creating new Auth0 account and starting over.

Not sure which configuration is throwing it off. FYI: snapshot:

1 reply
June 2020

konrad.sopala Community Engineer

Perfect! Glad to hear that!

June 2020 ▶ mfeldman143

andrea.chiarelli Auth0 Employee

Hey @mfeldman143, happy to hear you resolved the issue, even if we didn’t actually understand what happened.
At a high level, the snapshot you sent seems to highlight some issues on the Google connection. If you want to try to better understand, you can expand the Failed Exchange and Failed Login items to get more info.

June 2020

mfeldman143

Sorry. I had whitelist rules. That was the interference.

Regarding the Russian letters from Electron…I am getting that again this time from another scenario…my guess, something about the Electron npm packages.

1 reply
June 2020 ▶ mfeldman143

andrea.chiarelli Auth0 Employee

Sorry. I had whitelist rules. That was the interference.

Thank you for sharing. Al least we have a reason for the error :smiley:

Regarding the Russian letters from Electron…I am getting that again this time from another scenario…my guess, something about the Electron npm packages.

It’s possible

July 2020

robt1019

Hi. I’m quite new to OAuth/OpenId connect, so apologies if this is an obvious question.

What grant/flow is this example using? It looks like it is the Authorization Code flow, but as far as I can tell, you don’t pass a client secret.

Unless I’m missing something, according to the docs on the Auth0 Authentication API, it shouldn’t be possible to call the /oauth/token endpoint without either a client_secret (if using normal authorization code flow), or a code_verifier (if using Authorization code with PKCE)

To clarify, this is the call I’m confused about

 const exchangeOptions = {
    grant_type: "authorization_code",
    client_id: clientId,
    code: query.code,
    redirect_uri: redirectUri,
  };

  const options = {
    method: "POST",
    url: `https://${auth0Domain}/oauth/token`,
    headers: {
      "content-type": "application/json",
    },
    data: JSON.stringify(exchangeOptions),
  };

  try {
    const response = await axios(options);
1 reply
July 2020 ▶ robt1019

andrea.chiarelli Auth0 Employee

Hi @robt1019,
Welcome to the Auth0 Community and thanks for reading the blog post.

Regarding your question, your concerns are legitimate.
OAuth2 best practices suggest using the Authorization code with PKCE flow when using an external browser. However, for desktop applications (like Electron ones), there are a few issues in using the system browser mostly related to the user experience.

To learn more about this, please read the following thread and/or watch this video.

1 reply
August 2020

david-blox

Hi all,

I work on a new electron application with Auth0 and followed this guide to make it work:

In general it works pretty good but I have an issue with logout and login again from the same application instance.

When I logged in with a social app provider and then logout everything’s working good, but then when I try to log in again I get 401 Unauthorized when I call to /oauth/token with a code and grant type of authorization_code.

I thinks it’s related to the logout but I’m not sure about it.
When I logout I don’t see the ‘connection’ field in the logs even though I did see it on the first login.

on my logout function I’m clearing all the relevant tokens and data on the application side and also call this url to clear the session on the auth0 side:
https://${auth0.domain}/v2/logout?client_id=${auth0.clientID}

Best regards,
David

2 replies
August 2020

konrad.sopala Community Engineer

Thanks for reporting that. So as to work on that directly in a threat that is related to this blog article I’m moving it here from the separate thread.

August 2020 ▶ david-blox

dan-auth0 Auth0 Employee

Hey, David! My teammate who handles Electron is on vacation at the time so I apologize in advance if we have a delayed response :slight_smile: I’ll consult with him when he gets back about the issue that you are experiencing.

August 2020

pantneha47

Hi i tried using twitter with demo it was working fine but the moment my DEV account get verified and copy-paste my API key and Secret API Key, I started getting .catch error

(node:20797) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)

[1] (node:20797) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
1 reply
August 2020 ▶ pantneha47

pantneha47

These are my log image

1 reply
August 2020

konrad.sopala Community Engineer

Hey there @pantneha47!

Thanks for reporting that. We’ll look into that as soon as the article author is back at the “office”

August 2020 ▶ andrea.chiarelli

robt1019

Thanks for the reply @andrea.chiarelli . Sorry I didn’t get an alert so didn’t see you had replied! OK this makes sense. Very useful resources :slight_smile:

August 2020

konrad.sopala Community Engineer

Glad we were able to help!

August 2020 ▶ david-blox

andrea.chiarelli Auth0 Employee

Hey @david-blox,
Thank you for reading our tutorial.
Unfortunately, I’m not able to reproduce the error you reported.

I assume you cleared the local authentication data after logging out (see the logout() function in auth-service.js).

Do you get any log entry in your Auth0 dashboard related to the authorization code exchange?

Also, a track of the HTTP messages exchanged between the app and the Auth0 server could help to understand what is happening.

It would be great if you can provide this further information.

1 reply
August 2020 ▶ pantneha47

andrea.chiarelli Auth0 Employee

Hey @pantneha47,
Thank you for joining the Auth0 Community and reading the tutorial.
Unfortunately, the image you provided shows no details about the problem raised.
To help you solve your issue, it could be useful to take a look at the messages associated with the Failed Login and Failed Exchange log entries.
Please, can you provide those details?

August 2020 ▶ andrea.chiarelli

david-blox

Hi Andrea

This is what happened in the logs when user try to login → logout → login again.

When user try to login again from the login screen right after he clicked logout.
I get a message from auth0 api /token route:



The logout function run this:

logout = async () => {
  const { service, account } = this.keytar;
  await createLogoutWindow(`https://${this.auth.domain}/v2/logout?client_id=${this.auth.clientID}`);
  await keytar.deletePassword(service, account);
  storeService.logout();
  this.tokens = {
    accessToken: null,
    profile: null,
    refreshToken: null
  };
  this.userProfile = null; };

The logout window code:
import electron from 'electron';

const { BrowserWindow } = electron.remote;

export function createLogoutWindow(logOutUrl) {
  const logoutWindow = new BrowserWindow({
    show: false,
  });

  logoutWindow.loadURL(logOutUrl);

  logoutWindow.on('ready-to-show', async () => {
    logoutWindow.close();
  });
}

As you can see in the auth0 logs, even when the user have a successful login the /token api route returns 401 unauthorized.

If the user is closing the app opening it again and then try to login the /token route return a 200 OK.

Thanks a lot for your help,
David

1 reply
August 2020 ▶ david-blox

andrea.chiarelli Auth0 Employee

Hi @david-blox, at a first look I’m noticing nothing wrong in your code.

The 401 HTTP status code may lead me to think that the value of the client_id parameter is not correct, maybe due to any wrong assignment. I think of this as a remote possibility, but please, check if the value of the client_id parameter is correct when you get the 401 HTTP status code.

Also, is there any special reason you are specifying the client_id parameter in the logout URL?
Have you tried to not provide the client_id parameter?
Have you configured any Allowed Logout URLs in the Auth0 dashboard?
Please, check out this document to get more info about using the client_id parameter.

Let me know if any of these attempts resolve your issue.

September 2020

danielr

Hi,

Today google blocks rendering the login page on un-trusted browsers.
How does auth0 solve this issue for electron?

1 reply
September 2020

Atul

I have 2 electron applications running on my local machine,as per blog i have implemented auth0 in both apps and used same env-variables.json file in both applications.
On logout from my first application it deletes all tokens from my machine , when i open my second application it doesn’t get refresh token and it goes to create auth0 window.
But loadTokens method gets called automatically from webRequest.onBeforeRequest because url contains code query parameter(http://localhost/callback?code=pGgrRpkkMmSKls36). How can i delete all sessions on logout so my second application open auth0 window when there is no refresh token available.

1 reply
September 2020 ▶ danielr

andrea.chiarelli Auth0 Employee

Hi @danielr,
If you are experiencing issues with that Google decision, you should open the login page in the system browser with the shell.openExternal() method instead of using loadURL(), similarly to how it applied here.
However, in desktop applications, this implementation opens a few issues related to usability and integration with the operating system. For this reason, in general, for Electron we are not suggesting this approach.
If you want to learn more, check out the following links: