All Projects → mozilla → oauthorizer

mozilla / oauthorizer

Licence: other
DEPRECATED - Enable easy use of oauth for other addons

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to oauthorizer

iris
DEPRECATED - A Python 3 automation test tool for desktop applications
Stars: ✭ 18 (-30.77%)
Mutual labels:  abandoned, unmaintained
B2GOS-community
DEPRECATED - Tasks management for the B2G OS working groups
Stars: ✭ 11 (-57.69%)
Mutual labels:  abandoned, unmaintained
fxtest-jenkins-pipeline
DEPRECATED
Stars: ✭ 39 (+50%)
Mutual labels:  abandoned, unmaintained
iris firefox
DEPRECATED - Test Suite for Firefox using Mozilla Iris
Stars: ✭ 41 (+57.69%)
Mutual labels:  abandoned, unmaintained
lumbergh
DEPRECATED - Whaaaat's happening? Careers website... Mmmkay?
Stars: ✭ 19 (-26.92%)
Mutual labels:  abandoned, unmaintained
firefoxos-loop-client
DEPRECATED - Firefox OS client for the Loop service
Stars: ✭ 27 (+3.85%)
Mutual labels:  abandoned, unmaintained
b2g-installer
DEPRECATED - Tools to easily flash b2g on your android phone
Stars: ✭ 27 (+3.85%)
Mutual labels:  abandoned, unmaintained
Mozdef
DEPRECATED - MozDef: Mozilla Enterprise Defense Platform
Stars: ✭ 2,164 (+8223.08%)
Mutual labels:  abandoned, unmaintained
mozilla-download
DEPRECATED - Download firefox / b2g-desktop / mulet
Stars: ✭ 15 (-42.31%)
Mutual labels:  abandoned, unmaintained
markup
DEPRECATED - This projects has been retired.
Stars: ✭ 25 (-3.85%)
Mutual labels:  abandoned, unmaintained
npm-mirror
DEPRECATED - A utility for mirroring a subset of npm packages from another npm registry
Stars: ✭ 38 (+46.15%)
Mutual labels:  abandoned, unmaintained
i2c-tools
DEPRECATED - git conversion of http://lm-sensors.org/svn/i2c-tools subversion repo.
Stars: ✭ 34 (+30.77%)
Mutual labels:  abandoned, unmaintained
homeassistant-coronavirus-hessen
[Unmaintained] Home Assistant component to scrape the current SARS-CoV-2 data for the German state of Hessen from the website of the Hessisches Ministerium für Soziales und Integration.
Stars: ✭ 15 (-42.31%)
Mutual labels:  abandoned, unmaintained
addon-sdk
DEPRECATED - The Add-on SDK repository.
Stars: ✭ 643 (+2373.08%)
Mutual labels:  abandoned, unmaintained
Hasal
DEPRECATED - A Framework for testing web performance between different browser
Stars: ✭ 30 (+15.38%)
Mutual labels:  abandoned, unmaintained
murmur
DEPRECATED - A webapp for collecting speech samples for voice recognition testing and training
Stars: ✭ 20 (-23.08%)
Mutual labels:  abandoned, unmaintained
elmo
DEPRECATED - Elmo ~ https://mozilla.github.io/elmo/
Stars: ✭ 32 (+23.08%)
Mutual labels:  abandoned, unmaintained
Gaia
DEPRECATED - Gaia is a HTML5-based Phone UI for the Boot 2 Gecko Project. NOTE: For details of what branches are used for what releases, see
Stars: ✭ 2,091 (+7942.31%)
Mutual labels:  abandoned, unmaintained
valgrind
DEPRECATED - git-svn copy of the valgrind subversion repo. Firefox OS specific patches applied in "fxos" branch.
Stars: ✭ 22 (-15.38%)
Mutual labels:  abandoned, unmaintained
socialapi-dev
DEPRECATED - Experimental support for a Social API in Firefox
Stars: ✭ 41 (+57.69%)
Mutual labels:  abandoned, unmaintained

OAuthorizer

The OAuthorizer addon provides a way for chrome code to use OAuth without needing any knowledge of the details of the OAuth protocol. The only knowledge required is the OAuth keys and endpoints for initiating the OAuth authorization process.

OAuthorizer provides the following functionality:

  • Discoverability via XRD if the OAuth provider supports it
  • Standard OAuth dialog that wraps the providers authentication and authorization pages
  • Chrome code can specify any OAuth provider, or use a set of built-in providers
  • Chrome code must provide any OAuth keys necessary for the provider
  • A generic mechanism to call any arbitrary OAuth wrapped api call
  • OAuth 1 and 2 are supported
  • built-in oauth endpoints for Yahoo, Google, Facebook, LinkedIn, Plaxo and Twitter

TODO

  • Hide tokens from code using OAuthorizer
  • Move stored tokens into a secure store (current stored in prefs)
  • Make callback uri's unecessary for general use (ie. provide default)
  • Make some api's available from web content
  • Flesh out discovery code
  • Consider whether any providers should be built-in, or if the list should be expanded
  • code cleanup, documentation, reviews

Example use

Initiating authorization

Components.utils.import("resource://oauthorizer/modules/oauthconsumer.js");

let provider = 'google'; // just a key name for storing/retrieving data
let [key, secret, params, completionURI] = [
    "anonymous",
    "anonymous",
    {
    'xoauth_displayname': "Mozilla Authorizer",
    'scope': 'http://www.google.com/m8/feeds' 
    },
    "http://oauthcallback.local/access.xhtml"
];
let svc = null;

function authorizationCallback(svcObj) {
    dump("*********FINISHED**********\naccess token: "+
         svc.token+"\n  secret: "+svc.tokenSecret+"\n");
    svc = svcObj;
}
let handler = OAuthConsumer.authorize(provider, key, secret, completionURI, authorizationCallback, params);

Making an api call

let message = {
    action: 'http://www.google.com/m8/feeds/contacts/default/full',
    method: "GET",
    parameters: {'v':'2', "max-results":"2000"}
};

// req is an XMLHttpRequest object
// a more complete example is at
// https://hg.mozilla.org/labs/people/file/2a4b293fcbe7/modules/importers/gmail.js
oauthCallback(req) {
    log.info("Google Contacts API: " + req.status+" "+req.statusText);
    // you may need to handle a 401
    if (req.status == 401) {
        var headers = req.getAllResponseHeaders();
        if (req.statusText.indexOf('Token invalid') >= 0)
        {
            // start over with authorization
            OAuthConsumer.resetAccess(svc.name, svc.consumerKey, svc.consumerSecret);
            // have to call OAuthConsumer.authorize
            return;
        }
        else if (headers.indexOf("oauth_problem=\"token_expired\"") > 0)
        {
            handler.reauthorize();
            return;
        }
        // some other error we don't handle
        return;
    }
    
    // everything is good, process the response
}

// svc is retreived from the authorize callback above
OAuthConsumer.call(svc, message, oauthCallback);

Reset OAuth access

OAuthConsumer.resetAccess(provider, key, secret);

Using an OAuth provider that is not built into OAuthorizer

Adding a non-built-in OAuth provider requires a little more knowledge but not much. You must always do this once before any other calls into OAuthConsumer if you are accessing a non-built-in OAuth provider.

let providerName = 'yahoo';
let secret = "My Consumer Secret";
let key = "My Consumer Key";
let calls = {
      signatureMethod     : "HMAC-SHA1",
      requestTokenURL     : "https://api.login.yahoo.com/oauth/v2/get_request_token",
      userAuthorizationURL: "https://api.login.yahoo.com/oauth/v2/request_auth",
      accessTokenURL      : "https://api.login.yahoo.com/oauth/v2/get_token"
    };
let myprovider = OAuthConsumer.makeProvider(providerName, 'Yahoo!',
                                            key, secret,
                                            completionURI, calls);
// XXX should be handled internally by makeProvider
OAuthConsumer._providers[providerName] = myprovider;

Configuring an OAuth provider via XRD

XXX Discovery is simplistic, probably doesn't work 100%.

OAuthConsumer.discoverProvider(xrdsURI, providerName, displayName,
                               consumerKey, consumerSecret, redirectURL)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].