jbreckmckye / electron-auth0-login

Helper widget for Auth0 authentication in Electron desktop apps
MIT License
28 stars 19 forks source link

How to use it in a react based electron app? #31

Closed waptik closed 3 years ago

waptik commented 3 years ago

Hi! I just came across this package and i would like to use it in my app that's based on https://github.com/electron-react-boilerplate/electron-react-boilerplate.

I use https://github.com/sindresorhus/electron-store as my local data store. I use typescript so while using electron-store as the store for this package, i found out that it they were incompatible.

Any example of how to use a custom store with or without electron-store?

UPDATE: So i managed to create an object based on electron-store and the type error disappeared. Now the new issue that arose is the error received after setting the onClick of a react button to the function below:

async function getToken() {
    try {
      const token = await auth0.login();
      alert('getToken success ==>' + `See console`);
      console.info('Token:', token);
    } catch (e) {
      alert('getToken failed ==> ' + `See stdout. Error was "${e.message}"`);
      console.error(e);
    }
  }

The error ==>

HTTPError: Response code 400 (Bad Request)
    at Request.<anonymous> (F:\aye\nodejs\electron\MyApp\node_modules\electron-auth0-login\node_modules\got\dist\source\as-promise\index.js:117:42)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
jbreckmckye commented 3 years ago

I'm not sure why you're getting a Bad Request. Have you followed all the all the instructions in the setup guide? Does a login window appear before this exception, or does this error occur immediately? I'd advise double checking your Auth0 configuration and machine-to-machine client config.

waptik commented 3 years ago

The window opens and closes before the error shows in console and on screen. I'm on windows. After much thinking, i decided to clone the project locally and implement it directly in my project(installed required deps and removed anything keytar related) and it surprisingly worked.