Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
O

oauth2-client-bundle

> DevOps
Open source

Easily talk to an OAuth2 server for social functionality in Symfony

842 stars0 likes1 views
WebsiteGitHub

About

Easily talk to an OAuth2 server for social functionality in Symfony

OAuth / Social Integration for Symfony: KnpUOAuth2ClientBundle

Easily integrate with an OAuth2 server (e.g. Facebook, GitHub) for:

  • "Social" authentication / login
  • "Connect with Facebook" type of functionality
  • Fetching access keys via OAuth2 to be used with an API
  • Doing OAuth2 authentication with Symfony Custom Authenticator (or Guard Authenticator for legacy applications)

This bundle integrates with league/oauth2-client.

This Bundle or HWIOAuthBundle?

In addition to this bundle, another OAuth bundle exists for Symfony: hwi/oauth-bundle. You might be wondering "why are there two popular OAuth bundles?".

Great question! Generally speaking, hwi/oauth-bundle gives you more features out-of-the-box, including social authentication and registration (called "connect"). But, it's also a bit harder to install. The knpuniversity/oauth2-client-bundle, takes more work to setup, but gives you more low-level control.

Not sure which to use? If you need OAuth (social) authentication & registration, try hwi/oauth-bundle. If you don't like it, come back!

Installation

Install the bundle library via Composer by running the following command:

composer require knpuniversity/oauth2-client-bundle

If you're using Symfony Flex, the bundle will be automatically enabled. For older apps, enable it in your AppKernel class.

Awesome! Now, you'll want to configure a client.

Configuring a Client

You'll need to configure one client for each OAuth2 server (GitHub, Facebook, etc) that you want to talk to.

Step 1) Download the Client Library

Choose the one you want from this list and install it via Composer:

OAuth2 Provider How to Install
Amazon composer require luchianenco/oauth2-amazon
AppID composer require jampire/oauth2-appid
Apple composer require patrickbussmann/oauth2-apple
Auth0 composer require riskio/oauth2-auth0
Azure composer require thenetworg/oauth2-azure
Bitbucket composer require stevenmaguire/oauth2-bitbucket
Box composer require stevenmaguire/oauth2-box
Buddy composer require buddy-works/oauth2-client
Buffer composer require tgallice/oauth2-buffer
CanvasLMS composer require smtech/oauth2-canvaslms
Clever composer require schoolrunner/oauth2-clever
DevianArt composer require seinopsys/oauth2-deviantart
DigitalOcean composer require chrishemmings/oauth2-digitalocean
Discord composer require wohali/oauth2-discord-new
Disqus composer require antalaron/oauth2-disqus
Dribbble composer require crewlabs/oauth2-dribbble
Dropbox composer require stevenmaguire/oauth2-dropbox
Drupal composer require chrishemmings/oauth2-drupal
Elance composer require stevenmaguire/oauth2-elance
Eve Online composer require evelabs/oauth2-eveonline
Eventbrite composer require stevenmaguire/oauth2-eventbrite
Facebook composer require league/oauth2-facebook
Fitbit composer require djchen/oauth2-fitbit
Foursquare composer require stevenmaguire/oauth2-foursquare
FusionAuth composer require jerryhopper/oauth2-fusionauth
Geocaching composer require surfoo/oauth2-geocaching
GitHub composer require league/oauth2-github
GitLab composer require omines/oauth2-gitlab
Google composer require league/oauth2-google
HeadHunter composer require alexmasterov/oauth2-headhunter
Heroku composer require stevenmaguire/oauth2-heroku
Instagram composer require league/oauth2-instagram
Jira composer require mrjoops/oauth2-jira
Keycloak composer require stevenmaguire/oauth2-keycloak
KeycloakPkce composer require stevenmaguire/oauth2-keycloak
LinkedIn composer require league/oauth2-linkedin
MailRu composer require aego/oauth2-mailru
Microsoft composer require stevenmaguire/oauth2-microsoft
Mollie composer require mollie/oauth2-mollie-php
Odnoklassniki composer require aego/oauth2-odnoklassniki
Okta composer require foxworth42/oauth2-okta
Passage composer require malteschlueter/oauth2-passage
Paypal composer require stevenmaguire/oauth2-paypal
PSN composer require larabros/oauth2-psn
Salesforce composer require stevenmaguire/oauth2-salesforce
Slack composer require adam-paterson/oauth2-slack
Spotify composer require kerox/oauth2-spotify
SymfonyConnect composer require qdequippe/oauth2-symfony-connect
Strava composer require edwin-luijten/oauth2-strava
Stripe composer require adam-paterson/oauth2-stripe
Twitch Deprecated composer require depotwarehouse/oauth2-twitch
Twitch Helix composer require vertisan/oauth2-twitch-helix
Uber composer require stevenmaguire/oauth2-uber
Unsplash composer require hughbertd/oauth2-unsplash
Vimeo composer require saf33r/oauth2-vimeo
VKontakte composer require j4k/oauth2-vkontakte
Wave composer require qdequippe/oauth2-wave
Webflow composer require koalati/oauth2-webflow
Yahoo composer require hayageek/oauth2-yahoo
Yandex composer require aego/oauth2-yandex
Zendesk composer require stevenmaguire/oauth2-zendesk
Generic configure any unsupported provider

Don't see a provider you need in this list? Please, check the full list of third-party provider clients from league/oauth2-client. Otherwise, consider creating a generic client yourself.

Step 2) Configure the Provider

Awesome! Now, you'll configure your provider. For Facebook, this will look something like this:

…

Notice the two '%env(var)%'calls? Add these in your .env file, or to the vault. These are the credentials for the OAuth provider. For Facebook, you'll get these by registering your app on developers.facebook.com:

# .env
# ...

OAUTH_FACEBOOK_ID=fb_id
OAUTH_FACEBOOK_SECRET=fb_secret

See the full configuration for all the supported "types" in the Configuration section.

The type is facebook because we're connecting to Facebook. You can see all the supported type values below in the Configuration section.

Step 3) Use the Client Service

Each client you configured now has its own service that can be used to communicate with the OAuth2 server.

To start the OAuth process, you'll need to create a route and controller that redirects to Facebook. Because we used the key facebook_main above, you can simply:

…

Now, just go (or link to) /connect/facebook and watch the flow!

After completing the OAuth2 flow, the $client object can be used to fetch the user, the access token, or other things:

// get the user directly
$user = $client->fetchUser();

// OR: get the access token and then user
$accessToken = $client->getAccessToken();
$user = $client->fetchUserFromToken($accessToken);

// access the underlying "provider" from league/oauth2-client
$provider = $client->getOAuth2Provider();
// if you're using Faceb

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHPoauth2oauth2-clientsocial-integrationssymfony

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
CategoryDevOps
PricingOpen source

> Related tools

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理