Skip to content

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

Open
tquensen wants to merge 6 commits intochok:masterfrom
tquensen:master
Open

Added authentication with google and namespace support for sfMelodyUserFactory::createUser#51
tquensen wants to merge 6 commits intochok:masterfrom
tquensen:master

Conversation

@tquensen
Copy link
Copy Markdown

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 added 4 commits March 19, 2012 15:30
…dn't work anyway)


(Namespace requires the scope "https://www.googleapis.com/auth/plus.me" in the app.yml (again, this does not work with the "api" config param as namespace and scope are different)

Access own (public) google+ Profile info via $melody->ns('plus')->get('people/me');
@tquensen
Copy link
Copy Markdown
Author

Works now with google+ :)

Uses the google+ ID if available, the email otherwise (or null if none is available)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove this ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the problem was, that a call to $melody->get('people/me') was changed to 'people/default/full'

use scope: [https://www.googleapis.com/auth/userinfo.email, https://www.googleapis.com/auth/userinfo.profile] in app.yml and call $melody->ns('oauth2')->get('userinfo') to get the userdata and the unique iserid even if the requested account doesn't have a google+ profile
@tquensen
Copy link
Copy Markdown
Author

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
Copy link
Copy Markdown

zarpax commented Jul 13, 2012

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

@tquensen
Copy link
Copy Markdown
Author

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

@zarpax
Copy link
Copy Markdown

zarpax commented Aug 13, 2012

@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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants