the draft: http://tools.ietf.org/html/draft-ietf-oauth-v2-10

has some dark corners, for instance and seems that facebook has some slight
incompatibilities:
1) "expires" instead of "expires_in"
2) support for POST besides GET?
3) support for Basic Auth?
4) returns "application/www-url-encoded" data with Content-Type: text/plain

scaffolding example app (needs the CLIENT_ID and CLIENT_SECRET from
facebook):
https://code.google.com/r/michelecomitini-facebookaccess/source/browse/applications/helloFacebook

the login module for oauth2.0 itself:
https://code.google.com/r/michelecomitini-facebookaccess/source/browse/gluon/contrib/login_methods/oauth20_account.py

It has been tested only on facebook; to see how it has to be used look at:
https://code.google.com/r/michelecomitini-facebookaccess/source/browse/applications/helloFacebook/models/db.py

The "standard" defines no way to get the resources needed by get_user, so
each authentication provider needs a different implementation,
the following work with facebook.

class FaceBookAccount(OAuthAccount):
    """OAuth impl for FaceBook"""
    AUTH_URL="https://graph.facebook.com/oauth/authorize";
    TOKEN_URL="https://graph.facebook.com/oauth/access_token";

    def __init__(self, g):
        OAuthAccount.__init__(self, g, CLIENT_ID, CLIENT_SECRET,
                              self.AUTH_URL, self.TOKEN_URL)
        self.graph = None

    def get_user(self):
        '''Returns the user using the Graph API.
        '''

        if not self.accessToken():
            return None

        if not self.graph:
            self.graph = GraphAPI((self.accessToken()))

        user = None
        try:
            user = self.graph.get_object("me")
        except GraphAPIError:
            self.session.token = None
            self.graph = None

        if user:
            return dict(first_name = user['first_name'],
                        last_name = user['last_name'],
                        username = user['id'])




2010/7/14 ChrisM <[email protected]>

> sorry for posting my dumb comment,  just read oauth documents, didn't
> realise it was api specific.
> I like the look of geo social apps gowalla and foursquare, they also
> use oauth to connect to
> their api's.
> chrism
>
> On Jul 13, 6:12 pm, ChrisM <[email protected]> wrote:
> > +1
> > I am still using web2py1.73 as when I try and upgrade web2py the
> > rpxauth.py module i am using throws an error
> > because storage.py and  restricted.py must have changed.
> > error: self.setting.rpx_key does not exist
> >
> > It would be good to have a module that allowed for users to log in
> > from social apps accounts without developer having to have jainrain
> > account!
> > ChrisM
> >
> > On Jul 13, 5:24 pm, mdipierro <[email protected]> wrote:
> >
> > > I need a modified version of
> >
> > >    gluon/contrib/login_methods/linkedin_account.py
> >
> > > that works with oauth as explained herehttp://
> dougwarren.org/2010/06/oauth-and-web2py-part-1/,
> > > is integrated with web2py auth as linkedin_account.py, but also works
> > > out of the box with facebook and twitter.
> >
> > > If you have anything relevant please let me know.
> >
> > > Massimo
>

Reply via email to