chok / sfMelodyPlugin

Allow to communicate with many services(google, yahoo...) throw OAuth
MIT License
45 stars 21 forks source link

Added authentication with google and namespace support for sfMelodyUserFactory::createUser #51

Open tquensen opened 12 years ago

tquensen commented 12 years ago

There was no useful way to get basic user info for google accounts, so a added some changes:

a new "userinfo" namespace in the google class: https://www.googleapis.com/userinfo the required scope is "https://www.googleapis.com/auth/userinfo.email", so this does not work with the api config (for whatever reason, scope is different to namespace)

As this is not the default namespace, i added a parameter "namespace" to use with the user configuration.

So, to authenticate with google and retrieve the email, use this config:

  melody:
    ...

    google:
      key:  ...
      secret: ...
      callback: "@homepage"   # or absolute url

      # api: []  DOES NOT WORK      # only for google - easy way to set scopes
      scope: [https://www.googleapis.com/auth/userinfo.email]

      user:                       # to create an user
        email:
          call: email
          path: data.email
          key: true
          namespace: userinfo # use the namespace userinfo for the email-call, not the default one
tquensen commented 12 years ago

Works now with google+ :)

tquensen commented 12 years ago

I have changed the getIdentifier method to use only a single call. The required scope is "https://www.googleapis.com/auth/userinfo.profile" (and optionally "https://www.googleapis.com/auth/userinfo.email" for the email") I also added a new namespace 'oauth2' => 'https://www.googleapis.com/oauth2/v1' to get the userinfo. https://www.googleapis.com/oauth2/v1/userinfo doesn't return as much data as a call to the google+ profile, but you get a unique identifier for every google user, even for those without google+ profile

zarpax commented 12 years ago

I´m using this file version but doesn´t works

tquensen commented 12 years ago

@zarpax what exactly "doesn´t work"? Some more information would be helpful :)

zarpax commented 12 years ago

@tquensen, Sorry for the delay. I've been making new tries and all works ok. In my first try I couldn't connect with google (Token error)