Comments (7)
Thanks your question!
I will check and feedback soon 😄
from electron-oauth-helper.
hmm... When I tried electron-oauth-helper at electron-vue, no error occurred.
However, executing perform
before opening window caused an error.
But, that was different from the error you wrote.
May I ask you to try the following?
- Please check if the version of electron-oauth-helper in
package.json -> dependencies
is1.0.2
. - Please check if the version of nodejs you are using is 8.9.2.
- remove
dist
dir and runnpm run dev
Here is the code I tried.
function createWindow () {
/**
* Initial window options
*/
mainWindow = new BrowserWindow({
height: 563,
useContentSize: true,
width: 1000
})
mainWindow.loadURL(winURL)
mainWindow.on('closed', () => {
mainWindow = null
})
// Be careful!
// An error will occur if window is not opened
setTimeout(() => {
try {
const p = new OAuth2Provider({
// this is example
authorize_url: 'https://www.google.co.jp',
redirect_url: 'https://www.google.co.jp',
client_id: 'aa',
client_secret: 'aa'
})
p.perform({})
.then(() => {
console.log('aa')
})
.catch(console.error)
} catch (error) {
console.error(error)
}
}, 3000)
}
from electron-oauth-helper.
Hello, thanks for the answer ... I have the 1.0.2 version of electron-oauth-helper and node 8.9.2 ... I'm trying with your code and works 😃
Now I have to see if I can make the user register to firebase.
Many thanks
from electron-oauth-helper.
I will close the issue but please feel free to reopen if there is any problem.
from electron-oauth-helper.
Thanks, and Hello again 😅
Now i have a error with the token, that is my code:
'use strict'
import { app, BrowserWindow } from 'electron'
// const ipc = require('electron').ipcMain
/**
* Set `__static` path to static files in production
* https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
*/
if (process.env.NODE_ENV !== 'development') {
global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')
}
let mainWindow
const winURL = process.env.NODE_ENV === 'development'
? `http://localhost:9080`
: `file://${__dirname}/index.html`
const { OAuth2Provider } = require('electron-oauth-helper')
const mapTypeToConfig = require('../../services/config')
const Firebase = require('firebase')
Firebase.initializeApp(mapTypeToConfig('Firebase'))
// const queryString = require('query-string')
function createWindow () {
/**
* Initial window options
*/
mainWindow = new BrowserWindow({
height: 563,
useContentSize: true,
width: 1000
})
mainWindow.loadURL(winURL)
mainWindow.on('closed', () => {
mainWindow = null
})
mainWindow.setMenu(null)
Firebase.auth().onAuthStateChanged(function (user) {
console.log('user 1: ', user)
})
setTimeout(() => {
try {
const provider = new OAuth2Provider(mapTypeToConfig('GoogleClientWebApp'))
provider.perform().then(resp => {
// const query = queryString.parse(resp)
console.log('resp 1: ', resp['access_token'])
// console.log('resp 2: ', resp.getAuthResponse().id_token)
const credential = Firebase.auth.GoogleAuthProvider.credential(resp['access_token'])
Firebase.auth().signInWithCredential(credential)
.then(user => { console.log('user 2: ', user) })
.catch(error => console.error('error: ', error))
})
.catch(error => console.error(error))
} catch (error) {
console.error(error)
}
}, 3000)
}
app.on('ready', createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (mainWindow === null) {
createWindow()
}
})
The line is wrong??
const credential = Firebase.auth.GoogleAuthProvider.credential(resp['access_token'])
That is the error -->
error: { [Error: {"error":{"errors":[{"domain":"global","reason":"invalid","message":"Unable to parse Google id_token: //SECRET//"}],"code":400,"message":"Unable to parse Google id_token: //SECRET//"}}]
code: 'auth/internal-error',
message: '{"error":{"errors":[{"domain":"global","reason":"invalid","message":"Unable to parse Google id_token: //SECRET//"}],"code":400,"message":"Unable to parse Google id_token: //SECRET//"}}' }
The token it looks like this (//SECRET// is not the same :D )
yf59.GlwcxdLccCpL1EI9hLRPMekvy6xwgSEiijJhdPJyAjP4tZ7UTc6IsSbvohyyqjzlH5zBPzr8po699Y7HpfDJv66X4ktdDtGM6c95CfjvZ9tCz-IoaDxy6CDctysYTA
I can provide more info if you want.
from electron-oauth-helper.
Good morning! Japan is now at 8:00.
I got the same error when I tried connecting google and firebase auth.
And I finally found the right way. Here is example code.
// https://firebase.google.com/docs/reference/js/firebase.auth.GoogleAuthProvider#.credential
//**************************************************************↓ Be careful! first argument is null.
const credential = firebase.auth.GoogleAuthProvider.credential(null, resp.access_token)
firebase.auth().signInWithCredential(credential)
.then(result => {
console.log("joined google", result)
})
.catch(error => {
console.error(error)
})
And here is complete example code.
https://github.com/mironal/electron-oauth-helper/blob/master/example/src/render/index.js#L43
Enjoy! 😄
from electron-oauth-helper.
Good morning to 😃 ! Chile is now at 9:00
😮 Thanks is working now :D
Many thanks :)
from electron-oauth-helper.
Related Issues (20)
- OAuth2Provider is not a constructor
- Version 10 of node.js has been released
- Uncaught Error: client_id is required for code HOT 8
- Could not find a declaration file for module 'electron-oauth-helper' HOT 2
- Access Token Not Received HOT 3
- White page and no code after authorization HOT 1
- Rewrite TypeScript
- Not getting response from provder.perform(window) (Possible update) HOT 2
- This dependency was not found
- Problems with login by google account
- OAuth1Provider and OAuth2Provider is undefined HOT 1
- OAuth2-Authorize-URL is not created correctly when "authorize_url" configuration contains URL parameters
- TypeError: Cannot read property 'request' of undefined
- How do i config the redirect_uri when the app packet to Electron HOT 1
- How to add prompt settings to google oauth? HOT 1
- How to add prompt settings to Google OAuth? HOT 1
- Throw error in [email protected] HOT 2
- v5.0.2 can't install HOT 1
- How do ensure security in desktop apps?
- Facing issue in v5.1.0 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from electron-oauth-helper.