Meteor JS accounts-google package not working for me - meteor

I am a Meteor newbie and just ran into a problem using accounts-google (see below). All I did was follow the instructions on http://docs.meteor.com/#meteor_loginwithexternalservice. Any ideas on how to solve this issue and get Google login working? Thanks!
Terminal output:
W20141003-09:42:57.115(7)? (STDERR)
W20141003-09:42:57.116(7)? (STDERR) /Users/aw/.meteor/packages/meteor-tool/.1.0.33.alt9dq++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/fibers/future.js:173
W20141003-09:42:57.116(7)? (STDERR) throw(ex);
W20141003-09:42:57.117(7)? (STDERR) ^
W20141003-09:42:57.118(7)? (STDERR) ReferenceError: ServiceConfiguration is not defined
W20141003-09:42:57.119(7)? (STDERR) at app/server/accounts.js:26:1
W20141003-09:42:57.120(7)? (STDERR) at app/server/accounts.js:35:3
W20141003-09:42:57.120(7)? (STDERR) at /Users/aw/TS/.meteor/local/build/programs/server/boot.js:168:10
W20141003-09:42:57.120(7)? (STDERR) at Array.forEach (native)
W20141003-09:42:57.121(7)? (STDERR) at Function._.each._.forEach (/Users/aw/.meteor/packages/meteor-tool/.1.0.33.alt9dq++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/underscore/underscore.js:79:11)
W20141003-09:42:57.121(7)? (STDERR) at /Users/aw/TS/.meteor/local/build/programs/server/boot.js:82:5
=> Exited with code: 8
When I comment out my service configuration code (below)
// first, remove configuration entry in case service is already configured
ServiceConfiguration.configurations.remove({
service: "google"
});
ServiceConfiguration.configurations.insert({
service: "google",
clientId: "xxxxxxxx",
secret: "xxxxxxxxx"
});
It asks me to enter the clientId and secret from the bootstrap dropdown gui. Then nothing happens after that.
After I add service-configuration, I get the following error after logging in:

It turns out that in addition to meteor add service-configuration, you have to complete a minimum of all of the following in Google's API website:
https://console.developers.google.com/project
"Create Project"
Wait for the project to be provisioned
"API & auth" on the sidebar, "Credentials"
"Create new Client ID"
Paste in "Authorized JavaScript origin" and "Authorized Redirect URI"
"Create Client ID"
Copy the Client Secret and Client ID to your app configuration
"API & auth" on the sidebar "Consent screen"
Enter the field "Product Name" and save
Steps 9 & 10 appear to be new requirements from Google in the past few days. See this Github ticket regarding the issue.

You need to meteor add service-configuration manually.
The rest of your code looks good to me.
You also need to make sure that you configured things correctly in the Google Developers Console.
Add http://localhost:3000/_oauth/google?close in the REDIRECT URIS section, as well as http://localhost:3000/ for the JAVASCRIPT ORIGINS section.
This is for testing purpose on localhost, you'll need to add your deployed app actual ROOT_URL (http://www.example.com/) when pushing to production.
I addressed a similar problem here :
Meteor.user is null after (apparently) successful login

Related

Cannot read property 'manifest' of undefined Error in Ionic

I am trying to login Facebook with Firebase. I have installed all the libraries required and completed the required configuration. Still, whenever I try to start my app it is giving me this error:
(node:11160) UnhandledPromiseRejectionWarning: TypeError: Cannot read
property 'manifest' of undefined
at removeOldOptions (C:\Users\Dell\Desktop\firebaseapp\plugins\cordova- universal-links-plugin\hooks\lib\android\manifestWriter.js:48:32)ished in 37.33 s
at Object.writePreferences
(C:\Users\Dell\Desktop\firebaseapp\plugins\cordova-universal-links-
plugin\hooks\lib\android\manifestWriter.js:27:19)
at activateUniversalLinksInAndroid
(C:\Users\Dell\Desktop\firebaseapp\plugins\cordova-universal-links-plugin\hooks\afterPrepareHook.js:65:25)
at C:\Users\Dell\Desktop\firebaseapp\plugins\cordova-universal-links-plugin\hooks\afterPrepareHook.js:45:11
at Array.forEach (<anonymous>)
at run (C:\Users\Dell\Desktop\firebaseapp\plugins\cordova-universal-links-plugin\hooks\afterPrepareHook.js:41:17)
at module.exports (C:\Users\Dell\Desktop\firebaseapp\plugins\cordova-universal-links-plugin\hooks\afterPrepareHook.js:18:3)
at runScriptViaModuleLoader (C:\Users\Dell\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\HooksRunner.js:188:18)
at runScript (C:\Users\Dell\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\HooksRunner.js:164:16)
(node:11160) 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: 1)
Able to solve this with below changes :
Just go to the below file in Ionic
plugins/cordova-universal-links-plugin/hooks/lib/android/manifestWriter.js
I fixed issue by changing pathToManifest as below:
var pathToManifest = path.join(cordovaContext.opts.projectRoot, 'platforms', 'android', 'cordovaLib', 'AndroidManifest.xml');
to
var pathToManifest = path.join(
cordovaContext.opts.projectRoot,
'platforms',
'android',
'app',
'src',
'main',
'AndroidManifest.xml');
For anyone that's looking into this these days, the actual fix for this was published by someone which you can pull in as a cordova plugin https://github.com/nordnet/cordova-universal-links-plugin/issues/133#issuecomment-369260863
#okaufmann you can use the changed version of the plugin. since it's not merged in the nordnet repository, you must remove the plugin and install again using:
cordova plugin add https://github.com/walteram/cordova-universal-links-plugin
After doing...
cordova plugin rm cordova-universal-links-plugin
cordova plugin add https://github.com/walteram/cordova-universal-links-plugin
.. my project was able to build successfully.
You need to update the AndroidManifest path in the plugin, which seems to be outdated. Check out this:
https://github.com/nordnet/cordova-universal-links-plugin/issues/146

Error opening database, Cordova Web Browser

I am creating a database for an application in ionic 2, and it fails where I create it:
this.sqlite.create({
name: 'details.db',
location: 'default'
}).then((db: SQLiteObject) => {
//... }
Error:
OPEN database: details.db
Error: exec proxy not found for :: SQLitePlugin :: close
Error: exec proxy not found for :: SQLitePlugin :: open
OPEN database: details.db FAILED, aborting any pending transactions
Error: Could not open database
at newSQLError (SQLitePlugin.js:25)
at SQLitePlugin.js:198
at Object.module.exports [as exec] (cordova.js:1006)
at SQLitePlugin.js:207
at Object.module.exports [as exec] (cordova.js:1006)
at SQLitePlugin.open (SQLitePlugin.js:210)
at new SQLitePlugin (SQLitePlugin.js:84)
at Object.<anonymous> (SQLitePlugin.js:600)
at Object.openDatabase (SQLitePlugin.js:58)
at index.js:176
I have added the Cordova functionalities via ionic cordova platform add browser.
I run the app liko so:
ionic cordova run browser
Does it mean that this cordova functionality(create database) is not available in a browser?
You cannot open database via Cordova Web Browser.
What you can do is use the Emulator for Android provided by Visual Studio.
This way the database will be accessible.
It seems that you'll have to use a mock to be able to use browser environment with SQlite. I will try this, too: https://medium.com/#tintin301/ionic-sqlite-storage-setting-up-for-browser-development-and-testing-67c0f17fc7af
Some people warned about this so I would recommend this other approach:
https://forum.ionicframework.com/t/ionic-native-sqlite-issue/87416/18

Meteor: Cannot read property 'config' of undefined

I'm trying to implement the accounts-ui in a mobile angular-meteor app. I have all the dependencies installed, and I'm trying to setup the Accounts.ui.config with the following code:
import { Accounts } from 'meteor/accounts-base';
Accounts.ui.config({
passwordSignupFields: 'USERNAME_AND_EMAIL'
});
But when I try to run the app, I get the following error:
TypeError: Cannot read property 'config' of undefined
at meteorInstall.server.auth.js (server/auth.js:4:1)
at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:153:1)
at require (packages/modules-runtime/.npm/package/node_modules/install/install.js:82:1)
at server/publications.js:124:1
at /home/ubuntu/workspace/musiker/.meteor/local/build/programs/server/boot.js:297:10
at Array.forEach (native)
at Function._.each._.forEach (/home/ubuntu/.meteor/packages/meteor- tool/.1.4.0.hylsrj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
at /home/ubuntu/workspace/musiker/.meteor/local/build/programs/server/boot.js:133:5
I thought maybe I need to import accounts-ui for the page, but the docs clearly show importing the account-base. I also tried importing the accouns-ui and I still got the same error.
Thank!
-Erick
Add accounts package before using this.
Use this command in the project root to add the package
meteor add accounts-ui accounts-password
This should make your code work.
You need to add the config on client side code :
import { Accounts } from 'meteor/accounts-base';
Accounts.ui.config({
passwordSignupFields: 'USERNAME_ONLY',
});
Have a look here for more details.
It looks like you are trying to execute Accounts.ui.config on the server but this function is only available on the client.
It is Accounts.config.
Accounts.config({
passwordSignupFields: 'USERNAME_AND_EMAIL'
});
I have the same error.
First I put the JS into lib/startup/accounts-config.js or lib/accounts-config.js ,it still has error.
But it becomes effective when I put the JS into imports/startup/accounts-config.js. I don't know the reason.

How can I set forbidClientAccountCreation to false in Meteor?

The default setting in Meteor does not allow account creation from the Client, which makes sense for security purposes in many applications, but I am building a blog and need to allow users to create an account so they can leave comments.
The typical response on github, stackoverflow, and various tutorials seems to suggest adding the following code to your files, anywhere outside of the client/server conditionals, so that it can run on both client AND server:
Accounts.config({
forbidClientAccountCreation: false
});
Seems simple enough. I entered this bit of code in a file (configure.js) in my lib folder, but the following error message appears in the Terminal:
W20150925-19:52:17.568(9)? (STDERR) /Users/Eric/.meteor/packages/meteor-tool/.1.1.4.2l3p0l++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20150925-19:52:17.568(9)? (STDERR) throw(ex);
W20150925-19:52:17.568(9)? (STDERR) ^
W20150925-19:52:17.627(9)? (STDERR) Error: Can't set `forbidClientAccountCreation` more than once
W20150925-19:52:17.627(9)? (STDERR) at packages/accounts-base/accounts_common.js:95:1
W20150925-19:52:17.627(9)? (STDERR) at Array.forEach (native)
W20150925-19:52:17.627(9)? (STDERR) at Function._.each._.forEach (packages/underscore/underscore.js:105:1)
W20150925-19:52:17.628(9)? (STDERR) at Object.Accounts.config (packages/accounts-base/accounts_common.js:92:1)
W20150925-19:52:17.628(9)? (STDERR) at app/lib/configure.js:1:45
W20150925-19:52:17.628(9)? (STDERR) at app/lib/configure.js:5:3
W20150925-19:52:17.628(9)? (STDERR) at /Users/Eric/pilgrim/.meteor/local/build/programs/server/boot.js:222:10
W20150925-19:52:17.628(9)? (STDERR) at Array.forEach (native)
W20150925-19:52:17.628(9)? (STDERR) at Function._.each._.forEach (/Users/Eric/.meteor/packages/meteor-tool/.1.1.4.2l3p0l++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20150925-19:52:17.628(9)? (STDERR) at /Users/Eric/pilgrim/.meteor/local/build/programs/server/boot.js:117:5
=> Exited with code: 8
=> Your application is crashing. Waiting for file change.
The line "Can't set forbidClientAccountCreation more than once" seems to imply that the problem is stemming from multiple packages reasserting this same code in some manner.
I have a few packages such as accounts-ui, accounts-password, useraccounts:core, and useraccounts:foundation, but it appears that Meteor gets overwhelmed with conflicting signals (others have complained of a conflict with useraccounts:bootstrap as well.) I'm not certain if any of these are a direct source of conflict in my code, and other developers suggest removing any conflicting packages, but that seems like a poor solution. The packages were added for a reason. There should be a way to definitively set this variable without issue.
I can't seem to find a reasonable solution to this. Thoughts?
You can't set it to false while using the useraccounts:core package because that package sets it to true. The useraccounts suite provides a UI that should allow users to create accounts by default. You can't use the UI provided by accounts-ui to create your users (nor use Accounts.createUser() on the client) while using the useraccounts suite.
Meteor does allow account creation from the client.
It's best to think of how you have set up your project in terms of the packages you have added and/or removed and which block (server/client) is the code written.
Understanding which packages you have added/removed is the underlying factor as to how users can be created either from the client, and/or server.
Which package are you using to create a user?
The below is a simple example of creating a user from the client using the accounts-password package. The credentials a user provides here is an email address and password. Note, there are external packages in which to create users as well.
First:
meteor remove insecure
meteor add accounts-password
HTML:
<body>
{{> join}}
</body>
<template name="join">
<input type="email" id="email">
<input type="password" id="password" placeholder="6 charactors minimum">
<button class="submit"></button>
</template>
JS:
Template.join.events({
'click .submit': function(e, template) {
var email = template.find('#email').value;
var password = template.find('#password').value;
Accounts.createUser({
email: email,
password: password
},
function(error) {
if (error) {
console.log(error);
}
else {
console.log("account created");
}
});
}
});
Open the mongo shell and type db.users.find() and you will see the user that was created.
In future, it's best to pose a question providing further details that enable SO community to reproduce the code/problem and therefore, a resolution.
I am guessing that you have installed a package like useraccounts:bootstrap or useraccounts:materialize.
You can change this setting by changing the value of Accounts._options.forbidClientAccountCreation to true.

meteor deploying with 0.6.5

After I updated my Meteor app to 0.6.5 using
meteor update
and deployed it to my shared server (webfaction). I have a new error that appeared without me changing the application :
/home/me/webapps/meteor/bundle/programs/server/boot.js:184
}).run();
^
Error: a route URL prefix must begin with a slash
at _.extend.declare (packages/routepolicy/routepolicy.js:95)
at new StreamServer (packages/livedata/stream_server.js:23)
at new Server (packages/livedata/livedata_server.js:1029)
at Package (packages/livedata/server_convenience.js:10)
at packages/livedata.js:3907:4
at packages/livedata.js:3918:3
at /home/me/webapps/meteor/bundle/programs/server/boot.js:153:10
at Array.forEach (native)
at Function._.each._.forEach (/home/me/webapps/meteor/bundle/programs/server/node_modules/underscore/underscore.js:79:11)
at /home/me/webapps/meteor/bundle/programs/server/boot.js:80:5
Downgrading to 0.6.4.1 fixes the issue.
I would very much like to understand why the error is coming with 0.6.5
Check your ROOT_URL. Make sure it starts with http://
It might have something to do with changes to the package API in 0.6.5. See the release notes - http://www.meteor.com/blog/2013/08/14/meteor-065-namespacing-modularity-new-build-system-source-maps
And this meteor-talk thread - https://groups.google.com/d/topic/meteor-talk/BbrjGcGGIzc/discussion

Resources