Comments (9)
Interesting question - I was wondering the same thing. The ProviderUserDetails
way of doing it seems very static.
from eloquent-oauth.
+1
from eloquent-oauth.
Worked my way around this but this is not pretty. Not sure it’s the appropriate way to deal with this but I post it anyway if it can hint other users on a workaround.
I extended each provider (in my case, I only need LinkedIn) in my app namespace and overrided the $profileFields
property and the getUserDetails
function.
I also extended EloquentOAuthServiceProvider
and overrided the $providerLookup
property to register my new provider.
Then you need to register this service provider instead of the original one in config/app.php
from eloquent-oauth.
You're right, this must've been an oversight on my part during a refactoring, I'm sure this was more straightforward at some point.
Going to look into this and see what I can do :) Originally you just needed to say $details->customField
and it would work, if I remember correctly. Clearly not the case now, heh...
from eloquent-oauth.
Alright, I remember why I originally had that scopes option.
Since this package retrieves an access token you can use for later requests to the provider's API, I wanted to make sure that the token that came back had any additional scopes you might need. It wasn't meant to handle any additional data that came back from the initial request for a user's profile information.
That being said, I've pushed an update that stores all raw data that comes back from that request on the ProviderUserDetails
object, so it can be accessed however you need:
$details->raw()['birthday'];
...would get you what you need now :)
from eloquent-oauth.
Hi Adam,
thanks for the raw feature, but that doesn’t allow us to add additional fields to the $profileFields property of the provider.
Can you add a config for that?
from eloquent-oauth.
Only need to add the following line to the constructor of the Provider class:
if (isset($config['profileFields'])) {
$this->profileFields = array_merge($this->profileFields, $config['profileFields']);
}
from eloquent-oauth.
Ah you are specifically talking only about the LinkedIn Provider it seems, didn't catch that before. None of the other providers have that property and it's really just a special case for LinkedIn's API.
I don't think I'm really interested in adding too much built-in configuration for that sort of thing, as one of the main goals of the package is to handle normalization between providers of a specific set of common fields.
I think your original solution is actually an excellent and clean solution for your needs. Just extend the LinkedIn provider, add the fields you need (either hardcore or through config), and register it with your own service provider.
Custom LinkedIn provider:
class CustomLinkedInProvider extends LinkedInProvider
{
protected $profileFields = [
'id',
'first-name',
'last-name',
'email-address',
'picture-url',
'plus',
'any',
'others',
'you',
'might',
'need',
];
}
Custom service provider:
class CustomSocialLoginServiceProvider extends EloquentOAuthServiceProvider {
protected $providerLookup = [
'linkedin' => 'Your\\Custom\\LinkedInProvider',
];
}
That's literally the whole thing 👍
from eloquent-oauth.
Understood. Thanks for the sample code.
from eloquent-oauth.
Related Issues (20)
- Not catching ApplicationRejectedException when user reject facebook login HOT 3
- Add provider - Stripe [Request]
- Seems to be incompatible with Laravel 5.1 HOT 1
- Support passing custom data into the `state` param
- Provider Request: Reddit (code provided) HOT 7
- Class 'OAuth' not found HOT 2
- Add documentation for "Designing your users table"
- Rename OAuth facade HOT 2
- Support for twitter? HOT 3
- Request FACEBOOK basic data (gender, user_friends) HOT 1
- Office365 HOT 1
- Adding a 'remember' parameter to login() method HOT 1
- Retrieving The Authenticated User HOT 2
- Merging Accounts HOT 2
- Log in by access token HOT 2
- Using Google Oauth behind proxy
- Authorize more than one provider for one user HOT 1
- Running something on register HOT 1
- ¿Is There a way to auth sending email and password to Facebook or google?
- 'No query results for model [App\User].' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eloquent-oauth.