{"action":"created","issue":{"url":"https://api.github.com/repos/SocialiteProviders/Manager/issues/26","repository_url":"https://api.github.com/repos/SocialiteProviders/Manager","labels_url":"https://api.github.com/repos/SocialiteProviders/Manager/issues/26/labels{/name}","comments_url":"https://api.github.com/repos/SocialiteProviders/Manager/issues/26/comments","events_url":"https://api.github.com/repos/SocialiteProviders/Manager/issues/26/events","html_url":"https://github.com/SocialiteProviders/Manager/issues/26","id":135354260,"number":26,"title":"[Proposal] Own AbstractProviders with Custom Configuration","user":{"login":"DraperStudio","id":15245398,"avatar_url":"https://avatars.githubusercontent.com/u/15245398?v=3","gravatar_id":"","url":"https://api.github.com/users/DraperStudio","html_url":"https://github.com/DraperStudio","followers_url":"https://api.github.com/users/DraperStudio/followers","following_url":"https://api.github.com/users/DraperStudio/following{/other_user}","gists_url":"https://api.github.com/users/DraperStudio/gists{/gist_id}","starred_url":"https://api.github.com/users/DraperStudio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DraperStudio/subscriptions","organizations_url":"https://api.github.com/users/DraperStudio/orgs","repos_url":"https://api.github.com/users/DraperStudio/repos","events_url":"https://api.github.com/users/DraperStudio/events{/privacy}","received_events_url":"https://api.github.com/users/DraperStudio/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/SocialiteProviders/Manager/labels/in%20progress","name":"in progress","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2016-02-22T08:47:43Z","updated_at":"2016-03-26T19:11:43Z","closed_at":null,"body":"So I quickly put something together which makes it possible to have a fluent interface for the config which at the moment is somewhat clunky in my opinion - https://github.com/SocialiteProviders/StackExchange/issues/2#issuecomment-186761408\r\n\r\nThese changes would require the following changes to all Providers:\r\n\r\n- Provider.php has to extend `SocialiteProviders\\Manager\\OAuth1\\AbstractProvider` instead of the `Laravel\\Socialite\\One\\AbstractProvider`\r\n- Provider.php has to extend `SocialiteProviders\\Manager\\OAuth2\\AbstractProvider` instead of the `Laravel\\Socialite\\Two\\AbstractProvider`\r\n\r\nAdditionally we probably also should introduce our own `User` classes for both OAuth1 and OAuth2 to gain finer control over what is happening and the response data, which you already did for OAuth2.\r\n\r\n-----\r\n\r\n**OAuth2/AbstractProvider.php**\r\n```php\r\n<?php\r\nnamespace SocialiteProviders\\Manager\\OAuth2;\r\n\r\nuse GuzzleHttp\\ClientInterface;\r\nuse Laravel\\Socialite\\Two\\InvalidStateException;\r\nuse SocialiteProviders\\Manager\\SocialiteWasCalled;\r\n\r\nabstract class AbstractProvider extends \\Laravel\\Socialite\\Two\\AbstractProvider\r\n{\r\n    // all the code of the current AbstractProvider in the OAuth2 folder...\r\n\r\n    public function config(array $additionalConfig) {\r\n        $identifier = static::PROVIDER_IDENTIFIER;\r\n\r\n        $this->config = array_merge([\r\n            'client_id' => env(\"{$identifier}_KEY\"),\r\n            'client_secret' => env(\"{$identifier}_SECRET\"),\r\n            'redirect' => env(\"{$identifier}_REDIRECT_URI\"),\r\n        ], $additionalConfig);\r\n\r\n        return $this;\r\n    }\r\n\r\n    protected function getFromConfig($key)\r\n    {\r\n        $identifier = strtolower(static::PROVIDER_IDENTIFIER);\r\n\r\n        return app()['config'][\"services.{$identifier}\"][$key];\r\n    }\r\n}\r\n```\r\n\r\n**StackExchange/Provider.php**\r\n```php\r\n<?php\r\n\r\nnamespace SocialiteProviders\\StackExchange;\r\n\r\nuse SocialiteProviders\\Manager\\OAuth2\\AbstractProvider;\r\nuse SocialiteProviders\\Manager\\OAuth2\\User;\r\nuse Laravel\\Socialite\\Two\\ProviderInterface;\r\n\r\n/**\r\n * https://api.stackexchange.com/docs/authentication\r\n * Class Provider.\r\n */\r\nclass Provider extends AbstractProvider implements ProviderInterface\r\n{\r\n    const PROVIDER_IDENTIFIER = 'STACKEXCHANGE';\r\n\r\n    // all the code we have in the Provider.php file of each package at the moment...\r\n}\r\n```\r\n\r\n**routes.php**\r\n```php\r\nRoute::group(['middleware' => ['web']], function () {\r\n    \\Route::get('/', function() {\r\n        return \\Socialite::with('stackexchange')->config([\r\n            'key' => 'yourkeyfortheservice', 'site' => 'stackoverflow'\r\n        ])->redirect();\r\n    });\r\n\r\n    \\Route::get('/callback', function () {\r\n        $user = \\Socialite::with('stackexchange')->user();\r\n\r\n        dd($user);\r\n    });\r\n});\r\n```\r\n\r\n-----\r\n\r\nIf this seems like it goes into the right direction I will finish it up."},"comment":{"url":"https://api.github.com/repos/SocialiteProviders/Manager/issues/comments/201912750","html_url":"https://github.com/SocialiteProviders/Manager/issues/26#issuecomment-201912750","issue_url":"https://api.github.com/repos/SocialiteProviders/Manager/issues/26","id":201912750,"user":{"login":"DraperStudio","id":15245398,"avatar_url":"https://avatars.githubusercontent.com/u/15245398?v=3","gravatar_id":"","url":"https://api.github.com/users/DraperStudio","html_url":"https://github.com/DraperStudio","followers_url":"https://api.github.com/users/DraperStudio/followers","following_url":"https://api.github.com/users/DraperStudio/following{/other_user}","gists_url":"https://api.github.com/users/DraperStudio/gists{/gist_id}","starred_url":"https://api.github.com/users/DraperStudio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DraperStudio/subscriptions","organizations_url":"https://api.github.com/users/DraperStudio/orgs","repos_url":"https://api.github.com/users/DraperStudio/repos","events_url":"https://api.github.com/users/DraperStudio/events{/privacy}","received_events_url":"https://api.github.com/users/DraperStudio/received_events","type":"User","site_admin":false},"created_at":"2016-03-26T19:11:43Z","updated_at":"2016-03-26T19:11:43Z","body":"I agree that for different configurations per endpoint people should use the `config` method and I like the idea of the `configFromEnv` method.\r\n\r\nShould we maybe have the `configFromEnv` method called by default in the background? Meaning people would only need to enter their details in the `.env` file and no longer in both the `.env` and `services.php`"}}