kandi background
Explore Kits

socialite | Laravel wrapper around OAuth 1 & OAuth 2 libraries | OAuth library

 by   laravel PHP Version: v5.5.2 License: MIT

 by   laravel PHP Version: v5.5.2 License: MIT

Download this library from

kandi X-RAY | socialite Summary

socialite is a PHP library typically used in Security, OAuth applications. socialite has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.
Laravel Socialite provides an expressive, fluent interface to OAuth authentication with Facebook, Twitter, Google, LinkedIn, GitHub, GitLab and Bitbucket. It handles almost all of the boilerplate social authentication code you are dreading writing. Adapters for other platforms are listed at the community driven Socialite Providers website.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • socialite has a medium active ecosystem.
  • It has 5056 star(s) with 894 fork(s). There are 170 watchers for this library.
  • There were 6 major release(s) in the last 12 months.
  • There are 0 open issues and 156 have been closed. On average issues are closed in 16 days. There are no pull requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of socialite is v5.5.2
socialite Support
Best in #OAuth
Average in #OAuth
socialite Support
Best in #OAuth
Average in #OAuth

quality kandi Quality

  • socialite has 0 bugs and 5 code smells.
socialite Quality
Best in #OAuth
Average in #OAuth
socialite Quality
Best in #OAuth
Average in #OAuth

securitySecurity

  • socialite has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • socialite code analysis shows 0 unresolved vulnerabilities.
  • There are 1 security hotspots that need review.
socialite Security
Best in #OAuth
Average in #OAuth
socialite Security
Best in #OAuth
Average in #OAuth

license License

  • socialite is licensed under the MIT License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
socialite License
Best in #OAuth
Average in #OAuth
socialite License
Best in #OAuth
Average in #OAuth

buildReuse

  • socialite releases are available to install and integrate.
  • socialite saves you 382 person hours of effort in developing the same functionality from scratch.
  • It has 1034 lines of code, 133 functions and 23 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
socialite Reuse
Best in #OAuth
Average in #OAuth
socialite Reuse
Best in #OAuth
Average in #OAuth
Top functions reviewed by kandi - BETA

kandi has reviewed socialite and discovered the below as its top functions. This is intended to give you an instant insight into socialite implemented functionality, and help decide if they suit your requirements.

  • Get user information .
    • Get email by token
      • Get email address .
        • Get an access token .
          • Maps user data to user object .
            • Create the Facebook driver .
              • Map array of attributes .
                • Set the token .
                  • Register socialite services .
                    • Set the version .

                      Get all kandi verified functions for this library.

                      Get all kandi verified functions for this library.

                      socialite Key Features

                      Laravel wrapper around OAuth 1 & OAuth 2 libraries.

                      How can I structure this dataset for analysis & visualization? (Some columns contain lists instead of single values - Python & Pandas)

                      copy iconCopydownload iconDownload
                      cols = ['Summoner', 'Traits', 'Record_ID']
                      out = df.assign(Record_ID='id_' + df['Rank'].astype(str))[cols] \
                              .explode('Traits', ignore_index=True) \
                              .rename(columns={'Traits': 'Trait'})
                      print(out)
                      
                      # Output:
                         Summoner          Trait Record_ID
                      0     name1    7 Innovator      id_1
                      1     name1  1 Transformer      id_1
                      2     name1    3 Enchanter      id_1
                      3     name1    2 Socialite      id_1
                      4     name1    2 Clockwork      id_1
                      5     name1      2 Scholar      id_1
                      6     name1        2 Scrap      id_1
                      7     name2       1 Cuddly      id_2
                      8     name2      1 Glutton      id_2
                      9     name2    5 Mercenary      id_2
                      10    name2      4 Bruiser      id_2
                      11    name2     6 Chemtech      id_2
                      12    name2      2 Scholar      id_2
                      13    name2    1 Socialite      id_2
                      14    name2     2 Twinshot      id_2
                      

                      Missing required parameters for route (Laravel8)

                      copy iconCopydownload iconDownload
                      Route::get('/dashboard/profile', [
                            'as' => 'profile.show',
                          'uses' => 'ProfileController@show'
                      ]);
                      
                      Route::get('/profiles/{id}', [
                            'as' => 'profile.show',
                          'uses' => 'ProfileController@show'
                      ]);
                      
                      /**
                       * @param int $id
                       * @return View
                       */
                      public function show(int $id): View {
                          if (isset($id)) {
                              /* process parameter ID */
                          } else {
                              /* the own ID: Auth::user()->id */
                          }
                      }
                      
                      php artisan route:list
                      
                      Route::get('/dashboard/profile', [
                            'as' => 'profile.show',
                          'uses' => 'ProfileController@show'
                      ]);
                      
                      Route::get('/profiles/{id}', [
                            'as' => 'profile.show',
                          'uses' => 'ProfileController@show'
                      ]);
                      
                      /**
                       * @param int $id
                       * @return View
                       */
                      public function show(int $id): View {
                          if (isset($id)) {
                              /* process parameter ID */
                          } else {
                              /* the own ID: Auth::user()->id */
                          }
                      }
                      
                      php artisan route:list
                      
                      Route::get('/dashboard/profile', [
                            'as' => 'profile.show',
                          'uses' => 'ProfileController@show'
                      ]);
                      
                      Route::get('/profiles/{id}', [
                            'as' => 'profile.show',
                          'uses' => 'ProfileController@show'
                      ]);
                      
                      /**
                       * @param int $id
                       * @return View
                       */
                      public function show(int $id): View {
                          if (isset($id)) {
                              /* process parameter ID */
                          } else {
                              /* the own ID: Auth::user()->id */
                          }
                      }
                      
                      php artisan route:list
                      

                      Deployment Failed from Github via Code Pipeline

                      copy iconCopydownload iconDownload
                      composer self-update 2.1.3
                      
                      commands:
                        01updateComposer:
                          command: export COMPOSER_HOME=/root && /usr/bin/composer.phar self-update 2.1.3
                      
                      composer self-update 2.1.3
                      
                      commands:
                        01updateComposer:
                          command: export COMPOSER_HOME=/root && /usr/bin/composer.phar self-update 2.1.3
                      

                      Add to Laravel's built in Registration page Laravel 8

                      copy iconCopydownload iconDownload
                      php artisan make:observer UserObserver --model=User
                      
                      public function created(User $user)
                      {
                          //
                      }
                      
                      public function boot()
                      {
                          User::observe(UserObserver::class);
                      }
                      
                      php artisan make:observer UserObserver --model=User
                      
                      public function created(User $user)
                      {
                          //
                      }
                      
                      public function boot()
                      {
                          User::observe(UserObserver::class);
                      }
                      
                      php artisan make:observer UserObserver --model=User
                      
                      public function created(User $user)
                      {
                          //
                      }
                      
                      public function boot()
                      {
                          User::observe(UserObserver::class);
                      }
                      

                      Unable to get Keycloak client initiated client account linking to work

                      copy iconCopydownload iconDownload
                      import sjcl from "sjcl";
                      
                      hexToBase64(hexstring) {
                              return btoa(hexstring.match(/\w{2}/g).map(function(a) {
                                  return String.fromCharCode(parseInt(a, 16));
                              }).join(""));
                          },
                      
                      // Assume nonce, session_state, clientId, provider to be given
                      var data = nonce + session_state + clientId + provider;
                      var myBitArray = sjcl.hash.sha256.hash(data)
                      var hashedData = sjcl.codec.hex.fromBits(myBitArray)
                      var base64HashedData = this.hexToBase64(HashedData)
                      base64HashedData = base64HashedData.replaceAll('+','-').replaceAll('/','_').replaceAll('=','')
                      
                      

                      Laravel Socialite Facebook login not working ( AuthController does not exist )

                      copy iconCopydownload iconDownload
                      Route::get('login/facebook', 'AuthController@redirectToProviderFacebook')->name('auth.facebook.redirect');
                      

                      Received HTTP status code [401] with message "{"errors":[{"code":32,"message":"Could not authenticate you."}]}" when getting temporary credentials

                      copy iconCopydownload iconDownload
                      //config/app.php
                      
                      ....
                      ....
                      'providers' => [
                          ....
                          ....
                          Laravel\Socialite\SocialiteServiceProvider::class,
                      ],
                      
                      'aliases' => [
                          ....
                          ....
                          'Socialite' => Laravel\Socialite\Facades\Socialite::class,
                      ],
                      ....
                      ....
                      
                      composer require laravel/socialite
                      
                      # install
                      composer require socialiteproviders/twitter
                      
                      # register
                      protected $listen = [
                          \SocialiteProviders\Manager\SocialiteWasCalled::class => [
                              'SocialiteProviders\Twitter\TwitterExtendSocialite@handle'
                          ],
                      ];
                      
                      # configure
                      'twitter' => [
                          'client_id' => env('TWITTER_KEY'),
                          'client_secret' => env('TWITTER_SECRET'),
                          'redirect' => env('TWITTER_REDIRECT_URI'),
                      ]
                      
                      # start building
                      return Socialite::driver('twitter')->redirect();
                      
                      //config/app.php
                      
                      ....
                      ....
                      'providers' => [
                          ....
                          ....
                          Laravel\Socialite\SocialiteServiceProvider::class,
                      ],
                      
                      'aliases' => [
                          ....
                          ....
                          'Socialite' => Laravel\Socialite\Facades\Socialite::class,
                      ],
                      ....
                      ....
                      
                      composer require laravel/socialite
                      
                      # install
                      composer require socialiteproviders/twitter
                      
                      # register
                      protected $listen = [
                          \SocialiteProviders\Manager\SocialiteWasCalled::class => [
                              'SocialiteProviders\Twitter\TwitterExtendSocialite@handle'
                          ],
                      ];
                      
                      # configure
                      'twitter' => [
                          'client_id' => env('TWITTER_KEY'),
                          'client_secret' => env('TWITTER_SECRET'),
                          'redirect' => env('TWITTER_REDIRECT_URI'),
                      ]
                      
                      # start building
                      return Socialite::driver('twitter')->redirect();
                      
                      //config/app.php
                      
                      ....
                      ....
                      'providers' => [
                          ....
                          ....
                          Laravel\Socialite\SocialiteServiceProvider::class,
                      ],
                      
                      'aliases' => [
                          ....
                          ....
                          'Socialite' => Laravel\Socialite\Facades\Socialite::class,
                      ],
                      ....
                      ....
                      
                      composer require laravel/socialite
                      
                      # install
                      composer require socialiteproviders/twitter
                      
                      # register
                      protected $listen = [
                          \SocialiteProviders\Manager\SocialiteWasCalled::class => [
                              'SocialiteProviders\Twitter\TwitterExtendSocialite@handle'
                          ],
                      ];
                      
                      # configure
                      'twitter' => [
                          'client_id' => env('TWITTER_KEY'),
                          'client_secret' => env('TWITTER_SECRET'),
                          'redirect' => env('TWITTER_REDIRECT_URI'),
                      ]
                      
                      # start building
                      return Socialite::driver('twitter')->redirect();
                      

                      Using a URL instead of service name to connect services with docker compose

                      copy iconCopydownload iconDownload
                          login:
                              build:
                                  context: ${LOGIN}/vendor/laravel/sail/runtimes/8.0
                                  dockerfile: Dockerfile
                                  args:
                                      WWWGROUP: '${WWWGROUP}'
                              image: sail-8.0/app
                              environment:
                                  WWWUSER: '${WWWUSER}'
                                  LARAVEL_SAIL: 1
                                  XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
                                  XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
                              volumes:
                                  - '${LOGIN}:/var/www/html'
                              networks:
                                  sail:
                                    aliases:
                                      - login.test
                              depends_on:
                                  - mysql
                      

                      Encrypted Laravel model feilds do not update

                      copy iconCopydownload iconDownload
                       protected $casts = [
                              'email_verified_at' => 'datetime',
                              'github_oauth_token' => 'encrypted',
                              'github_oauth_refresh_token' => 'encrypted',
                          ];
                          
                      
                      public function setGithubOauthTokenAttribute($value)
                      {
                          $this->github_oauth_token = Crypt::encryptString($value);
                      }
                      
                      public function setGithubOauthRefreshTokenAttribute($value)
                          {
                              $this->github_oauth_refresh_token = Crypt::encryptString($value);
                          }
                      
                      public function setGithubOauthTokenAttribute($value)
                          {
                                $this->attributes['github_oauth_token ']= Crypt::encryptString($value);
                          }
                      
                          public function setGithubOauthRefreshTokenAttribute($value)
                              {
                                 $this->attributes['github_oauth_refresh_token ']= Crypt::encryptString($value);
                              }
                      
                       protected $casts = [
                              'email_verified_at' => 'datetime',
                              'github_oauth_token' => 'encrypted',
                              'github_oauth_refresh_token' => 'encrypted',
                          ];
                          
                      
                      public function setGithubOauthTokenAttribute($value)
                      {
                          $this->github_oauth_token = Crypt::encryptString($value);
                      }
                      
                      public function setGithubOauthRefreshTokenAttribute($value)
                          {
                              $this->github_oauth_refresh_token = Crypt::encryptString($value);
                          }
                      
                      public function setGithubOauthTokenAttribute($value)
                          {
                                $this->attributes['github_oauth_token ']= Crypt::encryptString($value);
                          }
                      
                          public function setGithubOauthRefreshTokenAttribute($value)
                              {
                                 $this->attributes['github_oauth_refresh_token ']= Crypt::encryptString($value);
                              }
                      
                       protected $casts = [
                              'email_verified_at' => 'datetime',
                              'github_oauth_token' => 'encrypted',
                              'github_oauth_refresh_token' => 'encrypted',
                          ];
                          
                      
                      public function setGithubOauthTokenAttribute($value)
                      {
                          $this->github_oauth_token = Crypt::encryptString($value);
                      }
                      
                      public function setGithubOauthRefreshTokenAttribute($value)
                          {
                              $this->github_oauth_refresh_token = Crypt::encryptString($value);
                          }
                      
                      public function setGithubOauthTokenAttribute($value)
                          {
                                $this->attributes['github_oauth_token ']= Crypt::encryptString($value);
                          }
                      
                          public function setGithubOauthRefreshTokenAttribute($value)
                              {
                                 $this->attributes['github_oauth_refresh_token ']= Crypt::encryptString($value);
                              }
                      

                      Use key and secret from database to implement Facebook login in laravel 8

                      copy iconCopydownload iconDownload
                      use Laravel\Socialite\SocialiteManager;
                      use Socialite;
                      use Laravel\Socialite\Two\FacebookProvider;
                      
                      public function redirectToFacebook(Request $request)
                      {
                          $fb = $this->configDriver($request);
                          return $fb->redirect();
                      }
                      
                      private function configDriver(Request $request, $domain = '', $driver = 'facebook')
                      {
                          $config['client_id'] = 'your_client_id';
                          $config['client_secret'] = 'your_client_secret';
                          $config['redirect'] = 'your_redirect_url';
                          return Socialite::buildProvider(FacebookProvider::class, $config);
                      }
                      
                      public function handleSocialCallback(Request $request, $domain = '', $driver = 'facebook')
                      {
                          $usr = $this->configDriver($request)->stateless()->user();
                          $name = $user->getName();
                          $email = $user->getEmail();
                          $facebook_id = $user->getId();
                          /*save data in db*/
                      }
                      
                      use Laravel\Socialite\SocialiteManager;
                      use Socialite;
                      use Laravel\Socialite\Two\FacebookProvider;
                      
                      public function redirectToFacebook(Request $request)
                      {
                          $fb = $this->configDriver($request);
                          return $fb->redirect();
                      }
                      
                      private function configDriver(Request $request, $domain = '', $driver = 'facebook')
                      {
                          $config['client_id'] = 'your_client_id';
                          $config['client_secret'] = 'your_client_secret';
                          $config['redirect'] = 'your_redirect_url';
                          return Socialite::buildProvider(FacebookProvider::class, $config);
                      }
                      
                      public function handleSocialCallback(Request $request, $domain = '', $driver = 'facebook')
                      {
                          $usr = $this->configDriver($request)->stateless()->user();
                          $name = $user->getName();
                          $email = $user->getEmail();
                          $facebook_id = $user->getId();
                          /*save data in db*/
                      }
                      
                      https://github.com/jd-patel/laravel-social-login
                      

                      Community Discussions

                      Trending Discussions on socialite
                      • Socialite: Login with Google Client error
                      • How can I structure this dataset for analysis & visualization? (Some columns contain lists instead of single values - Python & Pandas)
                      • Missing required parameters for route (Laravel8)
                      • Deployment Failed from Github via Code Pipeline
                      • Add to Laravel's built in Registration page Laravel 8
                      • Unable to get Keycloak client initiated client account linking to work
                      • Laravel Socialite Facebook login not working ( AuthController does not exist )
                      • Laravel Socialite - Upgrade Twitch scopes
                      • Login with Google in Laravel Backpack
                      • I want to visit homepage as a guest but facing login page continuously in Laravel
                      Trending Discussions on socialite

                      QUESTION

                      Socialite: Login with Google Client error

                      Asked 2022-Feb-28 at 11:52

                      I'm using stateless fromUserToken

                      and this is the error I'm getting:

                      "errors": {
                              "error": "Client error: `GET https://www.googleapis.com/oauth2/v3/userinfo?prettyPrint=false` resulted in a `401 Unauthorized` response:\n{\n  \"error\": \"invalid_request\",\n  \"error_description\": \"Invalid Credentials\"\n}\n",
                              "code": 401
                          }
                      
                      

                      this is my endpoint that I use, it worked with all the sections I have in

                      public function authenticate (Request $request, $provider) {
                              
                              //Validate provider
                              
                      
                      
                              // Authenticate
                              $userSocial  = null;
                              try {
                                  if ($provider == 'twitter') {
                                      $userSocial = Socialite::driver('twitter')->userFromTokenAndSecret($request->token, $request->token_secret);
                                  } else {
                                      $accessToken = $request->token;
                                      $userSocial = Socialite::driver($provider)->stateless()->userFromToken($accessToken);
                                  }
                              } catch (\Exception $e) {
                                  return $this->respondError('Login error',[
                                      'error' => $e->getMessage(),
                                      'code' => $e->getCode()
                                  ],401);
                              }
                              
                              $user       =   User::where([
                                  'provider' => $provider,
                                  'provider_id' => $userSocial->id
                              ])->first();
                      
                              if($user){
                                  $token = $user->createToken('api')->plainTextToken;
                                  return $this->respondWithToken($token, 'Logged in successfully', false);
                              } else {
                                  $user = User::create([
                                      'name'          => $userSocial->getName() ?: 'Apple User',
                                      'email'         => $userSocial->getEmail(),
                                      'image'         => $userSocial->getAvatar(),
                                      'provider_id'   => $userSocial->getId(),
                                      'provider'      => $provider,
                                  ]);
                                  $token = $user->createToken('api');
                                  return $this->respondWithToken($token, 'Registered successfully', true);
                              }
                          }
                      

                      Any Idea how to solve it? and this is the code I used

                      ANSWER

                      Answered 2022-Feb-28 at 11:52

                      The token that I was getting was jwt token, not access token. so It had problems with decoding it with stateless socialite function.

                      Source https://stackoverflow.com/questions/69589528

                      Community Discussions, Code Snippets contain sources that include Stack Exchange Network

                      Vulnerabilities

                      No vulnerabilities reported

                      Install socialite

                      You can download it from GitHub.
                      PHP requires the Visual C runtime (CRT). The Microsoft Visual C++ Redistributable for Visual Studio 2019 is suitable for all these PHP versions, see visualstudio.microsoft.com. You MUST download the x86 CRT for PHP x86 builds and the x64 CRT for PHP x64 builds. The CRT installer supports the /quiet and /norestart command-line switches, so you can also script it.

                      Support

                      Documentation for Socialite can be found on the Laravel website.

                      DOWNLOAD this Library from

                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 430 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      Explore Related Topics

                      Share this Page

                      share link
                      Consider Popular OAuth Libraries
                      Try Top Libraries by laravel
                      Compare OAuth Libraries with Highest Support
                      Compare OAuth Libraries with Highest Quality
                      Compare OAuth Libraries with Highest Security
                      Compare OAuth Libraries with Permissive License
                      Compare OAuth Libraries with Highest Reuse
                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 430 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      • © 2022 Open Weaver Inc.