Permalink
Browse files

initial commit

  • Loading branch information...
markomanninen committed Nov 15, 2011
0 parents commit 7c73ca1e03349f346c06289d240f09c5f96c690e
Showing with 1,649 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +5 −0 Cakefile
  3. +20 −0 LICENSE
  4. +57 −0 README.md
  5. +831 −0 lib/scribe.js
  6. +16 −0 lib/widgets.js
  7. +60 −0 lib/widgets/GoogleApi.js
  8. +37 −0 package.json
  9. +577 −0 src/scribe.coffee
  10. +5 −0 src/widgets.coffee
  11. +39 −0 src/widgets/GoogleApi.coffee
@@ -0,0 +1,2 @@
+/test
+.DS_Store*
@@ -0,0 +1,5 @@
+{exec} = require 'child_process'
+task 'build', 'Build project from src/*.coffee to lib/*.js', ->
+ exec 'coffee --compile --output lib/ src/', (err, stdout, stderr) ->
+ throw err if err
+ console.log stdout + stderr
20 LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2011 Marko Manninen
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,57 @@
+# How to use scribe library
+
+These small code snippets shows only general OAuth dance routines. On final application storing tokens on steps differs a lot depending on how application is done.
+
+ scribe = require 'scribe'
+ widgets = require('widgets').getWidgets(['GoogleApi', 'FacebookApi'])
+
+## Get authorization url
+
+ get_authorization_url = (service) ->
+ request_token_extract = (extractor, response) ->
+ # request token should be saved somewhere because service.getAccessToken uses request token
+ request_token = extractor response
+ console.log request_token
+ url = service.getAuthorizationUrl request_token
+ console.log url
+
+ service.getRequestToken request_token_extract
+
+# Save verification code to the datastore or session
+
+ set_verification_code = (code) ->
+ # save to datastore for example
+
+# Get verifier you got from clicking and following the authorization url on earlier steps
+
+ get_verification_code = () ->
+ code = 'verification_code'
+ new scribe.Verifier code
+
+## Get request token from datastore or session after get_authorization_url
+
+ get_request_token = () ->
+ token = 'request_token'
+ secret = 'request_secret'
+ new scribe.Token token, secret
+
+## Set and save access token to datastore or session
+
+ set_access_token = (service) ->
+ access_token_extract = (extractor, response) ->
+ access_token = extractor response
+ console.log access_token
+ #save access token for late usage
+
+ service.getAccessToken get_request_token(), get_verifier(), access_token_extract
+
+# Get from datastore or session after set_access_token.
+
+This will return the final token you would use to retrieve data via selected web service. All earlier steps are just preparing and completing authorization for the service.
+
+ get_access_token = () ->
+ token = 'access_token'
+ secret = 'access_secret'
+ new scribe.Token token, secret
+
+# For example
Oops, something went wrong.

0 comments on commit 7c73ca1

Please sign in to comment.