ITeye博客

Hybrid(4)Favorite Places - Google Login

sillycat · 2015-09-01 02:02 · Summary · Mobile Platform · 企业架构 · Markdown

Hybrid(4)Favorite Places - Google Login

Requirements:

  1. Google Login
  2. CRUD Places
  3. CRUD Events

Create meteor in an existing directory. https://github.com/aldeed/meteorify

Then I can directly go to the project directory.

meteorify

This command will show us we already have the meteor env

meteor update

I create the favicon here. http://www.favicon.cc/

I create and place this icon in the directory public/favicon.ico.

Add the routes ability, add angular, these tools will be added to

vi .meteor/packages

meteor add urigo:angular meteor add angularui:angular-ui-router

It loads the files in sub directory first, and then the main directory.

remove the secure

meteor remove insecure

Add user and password

meteor add accounts-password meteor add accounts-ui

meteor add accounts-facebook meteor add accounts-twitter meteor add accounts-google meteor add pauli:accounts-linkedin meteor add accounts-github

Set up Google API - create the Project first from here https://code.google.com/apis/console/ Go to “APIs&auth” —> “Consent Screen” —> Make sure we have project names there

Go to “APIs&auth” —> “Credentials” —> Create new Client ID —> I chose web application Redirect URIs

  • http://localhost:3000/_oauth/google

JavaScript origins

  • http://localhost:3000/

Configure the things there, it is working well.

Privacy and Publish

meteor remove autopublish

Here is how to connect to the mongo db

meteor mongo

some mongo command

meteor:PRIMARY> show dbs meteor:PRIMARY> show collections meteor:PRIMARY> db.places.find(); { "_id" : "pkFtw59utKc8qtmBz", "name" : "Commons Ford Park", "desc" : "A good place for fishing." } { "_id" : "mgifXhdz7wCvigLTM", "name" : "Brushy creek park", "desc" : "It is close." } { "_id" : "BFXexh6wEd5GBDJGN", "name" : "Lago", "desc" : "It is far." }

Latest JSON format is here http://angular-meteor.com/tutorials/angular1/privacy-and-publish-subscribe-functions

Deploy the App

meteor deploy sillycat.meteor.com this will just deploy the things directly to meteor, I will check how to deploy it myself.

Running Android or iOS load the angular application in app.js //load the modules angular.module('favorite',['angular-meteor', 'ui.router']);

function onReady(){ angular.bootstrap(document, ["favorite"]); }

if(Meteor.isCordova){ angular.element(document).on("deviceready", onReady); }else{ angular.element(document).ready(onReady); }

Remove the index.html ng-app part

How to submit to Play Store https://github.com/meteor/meteor/wiki/How-to-submit-your-Android-app-to-Play-Store

How to submit to Apple Store https://github.com/meteor/meteor/wiki/How-to-submit-your-iOS-app-to-App-Store

Oauth is only working in iOS simulator right now https://github.com/meteor/meteor/wiki/OAuth-for-mobile-Meteor-clients

meteor run ios

Deploy to meteor

meteor deploy sillycat.meteor.com

Run the android

meteor run android --mobile-server http://sillycat.meteor.com

How to Customer Login and Configuration http://docs.meteor.com/#/full/meteor_loginwithexternalservice http://meteor.hromnik.com/blog/login-with-facebook-twitter-and-google-in-meteor http://themeteorchef.com/recipes/roll-your-own-authentication/ https://github.com/lc3t35/googlelogin

Meteor source codes for OAuth https://github.com/meteor/meteor

meteor/packages/oauth/oauth_common.js meteor/packages/oauth/oauth_cordova.js

We can easily login with google and github after using this command.

meteor add accounts-github meteor add accounts-google

But that will put a lot of user tokens and informations in users table. I may check the customer Oauth login.

Check the Accounts API http://docs.meteor.com/#/full/accounts_api

Take the code samples from here https://github.com/lc3t35/googlelogin https://github.com/m2web/githublogin https://www.eventedmind.com/feed/meteor-customizing-login http://docs.meteor.com/#/full/accounts_validatenewuser http://angular-meteor.com/api/auth

That is the scopes info scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fgmail.readonly+profile

Google Request https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=399670218895-7udn2k468l25g1rfta91djdbrklrs0p1.apps.googleusercontent.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fgmail.readonly+profile&redirect_uri=http://localhost:3000/_oauth/google&state=eyJsb2dpblN0eWxlIjoicmVkaXJlY3QiLCJjcmVkZW50aWFsVG9rZW4iOiJVQUR1YWxvdmxOeUtoWFROUkQ5cG5KUVFOOG53QTlTczVrcHIteFNDUVk4IiwiaXNDb3Jkb3ZhIjpmYWxzZSwicmVkaXJlY3RVcmwiOiJodHRwOi8vbG9jYWxob3N0OjMwMDAvcGxhY2VzIn0=&access_type=online&login_hint=luohuazju@gmail.com

https://accounts.google.com/o/oauth2/auth?prompt=consent&response_type=code&client_id=399670218895-7udn2k468l25g1rfta91djdbrklrs0p1.apps.googleusercontent.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fgmail.readonly%20profile&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2F_oauth%2Fgoogle%3Fclose&state=eyJsb2dpblN0eWxlIjoicmVkaXJlY3QiLCJjcmVkZW50aWFsVG9rZW4iOiJMRGZXVko0NExfZGNKSTJpdDNaSXk3UW9id2JuaklvSWRxX1pNZ1NfWlh5IiwiaXNDb3Jkb3ZhIjpmYWxzZSwicmVkaXJlY3RVcmwiOiJodHRwOi8vbG9jYWxob3N0OjMwMDAvIn0%3D&login_hint=luohuazju@gmail.com

Login hint https://developers.google.com/identity/protocols/OpenIDConnect

We will need latest meteor to support the login hint.

git clone git://github.com/meteor/meteor.git cd meteor/ ./scripts/generate-dev-bundle.sh ./meteor --version

Remove the old meteor

rm -fr ~/.meteor/ sudo rm /usr/local/bin/meteor

Link the directory to path and verify the installation

meteor --version Unreleased, running from a checkout at 927745a (HEAD, origin/devel, origin/HEAD, devel)

go to your working directory, update the current project

rm -fr .meteor/local/* meteor update meteor update --allow-incompatible-update

Run the application after update

meteor --settings settings.json run ios

Switch to the current meteor version

git checkout v0.5.2

Check the version

./meteor --version It's the first time you've run Meteor from a git checkout. I will download a kit containing all of Meteor's dependencies. ######################################################################## 100.0% Installed dependency kit v0.2.8 in dev_bundle. Meteor version 0.5.2 (git checkout) . ~/.profile meteor --version Meteor version 0.5.2 (git checkout)

Download the try the current release version https://github.com/meteor/meteor/releases https://github.com/meteor/meteor/releases/tag/release%2FMETEOR%401.1.0.3

Login Hint is an open issue on meteor, but I failed to build the source codes https://github.com/meteor/meteor/issues/2422

The fix is here https://github.com/bradvogel/meteor/tree/add-loginHint-oauth-param

Changes of the files https://github.com/meteor/meteor/pull/2790/files

Publish and Call http://docs.meteor.com/#/full/meteor_users

It seems that this version works https://github.com/meteor/meteor/tree/release-1.2

How to Deploy on Local $ (cd programs/server && npm install) $ export MONGO_URL='mongodb://user:password@host:port/databasename' $ export ROOT_URL='http://example.com' $ export MAIL_URL='smtp://user:password@mailhost:port/' $ node main.js

Tips: Run the linter with ./scripts/admin/eslint/eslint.sh

If you know what you are doing you can disable this check using:

git config hooks.ignore-eslint true

References: https://developers.google.com/apis-explorer/#p/ https://www.googleapis.com/auth/userinfo.profile https://developers.google.com/+/web/samples/java https://github.com/googleplus/gplus-quickstart-java

scopes http://itquestionz.com/questions/3346410/how-to-request-extra-oauth-scopes-in-meteor-accounts

meteor DDP https://meteorhacks.com/discover-meteor-ddp-in-realtime http://stackoverflow.com/questions/25373648/how-to-view-meteor-ddp-traffic/25373867#25373867 https://github.com/rclai/meteor-ddp-inspector http://meteorpedia.com/read/DDP_Clients

build client meteor build https://github.com/frozeman/meteor-build-client

functional test http://arunoda.github.io/laika/

performance test https://meteorhacks.com/cluster-performance-test-its-impressive https://github.com/meteorhacks/meteor-down

Redis https://github.com/meteor/redis-livedata

AWS https://github.com/peerlibrary/meteor-aws-sdk

jslint http://blog.philippundhee.ch/lint-your-meteor-project/

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。