Skip to content

Commit

Permalink
rolling a new version with support for node versions greater than 0.4.6
Browse files Browse the repository at this point in the history
changed some docs too
  • Loading branch information
markomanninen committed Nov 26, 2011
1 parent 3eaf327 commit 0182fc3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
34 changes: 18 additions & 16 deletions README.md
Expand Up @@ -16,12 +16,28 @@ Source files are made with coffeescript as it provides seemingly cleaner and man

npm install scribe-node

Next steps are to demostrate retrieving authorization token and use it on your application to access data from web service. See Google analytics example at the end of the read me file. Examples uses OAuth 1.0a scheme. Later OAuth 2.0 examples will be added.
## Widgets (APIs)

Note that I'm using offpage application mode for authorization. It means callback page is set to `oob` which causes service provider to show verification code on browser window. Then you need to paste code to your application manually. Approach is a little bit different on fully pledged web appliations, that can hide this part of the process behind the screen.
OAuth widget is to fully demonstate OAuth process on application. One should carefully explore source from https://github.com/mmstud/scribe-node/blob/master/src/widgets/OAuth.coffee

Using widget would be as simple as:

scribe = require('scribe-node').load(['OAuth'])
services = {}
services['analytics'] = {'provider': scribe.GoogleApi, 'key': '{YOUR_KEY}', 'secret': '{YOUR_SECRET}', 'scope': 'https://www.google.com/analytics/feeds/', 'callback': 'oob'}
service = new scribe.OAuth({}, 'analytics', services)
service.get_authorization_url((url) -> console.log url)

# after getting code execute rest of the script
service.set_verification_code('{CODE}', (response) -> console.log response)
access_token = service.get_access_token()

## OAuth 1.0a Dance Snippets

Next steps are to demostrate retrieving authorization token in smaller pieces (if above method is not working for you for some reason) and use it on your application to access data from web service. See Google analytics example at the end of the read me file. Examples uses OAuth 1.0a scheme. Later OAuth 2.0 examples will be added.

Note that I'm using offpage application mode for authorization. It means callback page is set to `oob` which causes service provider to show verification code on browser window. Then you need to paste code to your application manually. Approach is a little bit different on fully pledged web appliations, that can hide this part of the process behind the screen.

### Get authorization url

get_authorization_url = (service) ->
Expand Down Expand Up @@ -131,20 +147,6 @@ And then from coffee eval loop:

If you do a lot of interaction with Google Analytics or other Google services, you may want to create own model for more sophisticated approach, buts its beyond the scope of this work.

## Widgets (APIs)

__New:__

OAuth widget is to fully demonstate OAuth process on application. One should carefully explore source from https://github.com/mmstud/scribe-node/blob/master/src/widgets/OAuth.coffee

Using widget would be as simple as:

scribe = require('scribe-node').load(['OAuth'])
service = new scribe.OAuth({}, 'analytics')
service.get_authorization_url((url) -> console.log url)
service.set_verification_code('{code}', (response) -> console.log response)
access_token = service.get_access_token()

### Supported and tested widget list

These are the specialized APIs that are already implemented on scribe-node library. Althought limited list of APIs mentiond here, it doesnt mean to you cannot use library with any other web service available from internet. Library should work with all OAuth 1.0a and 2.0 schemes. If you have made your own API, please dont hesitate to fork this repository, add API as a widget to the library and send a pull request.
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -2,7 +2,7 @@
"name": "scribe-node",
"description": "Scribe java OAuth library port to node.js",
"author": "Marko Manninen <mmstud@gmail.com> (http://about.me/markomanninen)",
"version": "0.0.20",
"version": "0.0.21",
"homepage": "https://github.com/mmstud/scribe-node",
"keywords": ["scribe","oauth","web2.0","node.js","coffeescript","java","google","api"],
"licenses": [{
Expand All @@ -26,6 +26,6 @@
"coffee-script": ">=1.1.3"
},
"engines": {
"node": "~0.4"
"node": ">= 0.4.7"
}
}
1 change: 0 additions & 1 deletion src/scribe.coffee
Expand Up @@ -21,7 +21,6 @@ crypto = require 'crypto'
root.load = (apis) ->
for api in apis
root[api] = require('./widgets/' + api)[api]
#eval('root.'+api+' = require("./widgets/'+api+'").'+api)
return this

# Verifier class
Expand Down
5 changes: 3 additions & 2 deletions src/widgets/OAuth.coffee
Expand Up @@ -12,9 +12,10 @@
# - public methods by OAuth class are:
# 1. get_authorization_url which takes callback function to return url / false
# 2. set_verification_code which takes code and callback function to return true/false
# 3. refresh_access_token which is used by OAuth 2.0 schemes only and which takes access_token and
# 3. set_access_token_code which is used by OAuth 2.0 schemes only which takes code and return true/false
# 4. refresh_access_token which is used by OAuth 2.0 schemes only and which takes access_token and
# callback function to return true/false
# 4. get_request_token, get_access_token and get_verifier methods to retrieve tokens as per method name
# 5. get_request_token, get_access_token and get_verifier methods to retrieve tokens as per method name
#
# TODO:
# - signatureType on default service configurations is not used yet, but its possible and maybe
Expand Down

0 comments on commit 0182fc3

Please sign in to comment.