Coder Social home page Coder Social logo

amobiz / everjs Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 195 KB

A Sample of jsOAuth plugin for Google Chrome Extension - using Evernote SDK for JavaScript with Basic Access Permissions.

License: MIT License

JavaScript 84.06% CSS 5.20% HTML 10.74%

everjs's Introduction

A Sample of jsOAuth plugin for Google Chrome Extension - using Evernote SDK for JavaScript with Basic Access Permissions

This sample uses the following libraries:

This sample is based on the Evernote SDK for JavaScript Quick-start Guide. (Note that the sample code listed on the Quick-start Guide is somehow not working, please checkout directly to the PhoneGap example using the Evernote SDK for JavaScript for working sample source code.)

You'll need to create an account on Evernote development server. And then Get An API Key and fill in the consumerKey and consumerSecret in your code.

You can revoke access authorization on Applications management page.

Please checkout the Evernote Developer Documentation for complete Evernote API reference.

Released under the MIT. Please see LICENSE in the project root folder for more information.

Tutorial

This sample uses Yeoman, please checkout yeoman.io for installation and tutorial.

    yo chrome-extension
  • Add required libraries.
    bower install evernote
    bower install git://bytespider.github.com/jsOAuth.git
    bower install git://github.com/amobiz/jsOAuthChromeEx.git
  • In manifest.json, add the required scripts for event/background page.
    "background": {
        "scripts": [
            "bower_components/evernote/evernote-sdk-js/thrift/lib/thrift.js",
            "bower_components/evernote/evernote-sdk-js/thrift/lib/thrift-binary.js",
            "bower_components/evernote/evernote-sdk-js/generated/Errors_types.js",
            "bower_components/evernote/evernote-sdk-js/generated/Limits_types.js",
            "bower_components/evernote/evernote-sdk-js/generated/NoteStore.js",
            "bower_components/evernote/evernote-sdk-js/generated/NoteStore_types.js",
            "bower_components/evernote/evernote-sdk-js/generated/Types_types.js",
            "bower_components/evernote/evernote-sdk-js/generated/UserStore.js",
            "bower_components/evernote/evernote-sdk-js/generated/UserStore_types.js",
            "bower_components/jsOAuth/dist/jsOAuth-1.3.7.js",
            "bower_components/jsOAuthChromeEx/app/scripts/jsOAuthChromeEx.js",
            "scripts/chromereload.js",
            "scripts/client.js",
            "scripts/background.js"
        ]
    },

Don't use the minified version of evernote-sdk-js, because we need the "authenticationToken" veriable be reserved, as in the next step.

  • In Gruntfile.js, add keyword "authenticationToken" to except in uglify.
    uglify: {
        options: {
            mangle: {
                except: ['authenticationToken']
            }
        }
    },
  • In manifest.json, add "web_accessible_resources".
    "web_accessible_resources": [
        "oauth.html"
    ],
    "permissions": [
        "tabs",
        "https://sandbox.evernote.com/"
    ]
  • In background.js, setup the jsOAuth:
    OAuth.initBackgroundPage();
  • To authorize using OAuth, create an Evernote.Client object, and then call it's authorize method.
    var client = new Evernote.Client({
        consumerKey: 'your consumerKey',
        consumerSecret: 'your consumerSecret',
        sandbox: true
    });

    client.authorize(function() {
        noteStore = client.getNoteStore();
        // call noteStore's method to access Evernote API.
    }, function( error ) {
        handleEDAMException( error );
    });

You'll need to replace the consumer key and secret with your own.

  • Load the sample Chrome Extension in developer mode.

    Please checkout Load the extension for instruction.

  • Checkout evernote.js for usage examples.

Authors

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.