I have a question maybe useful for most of Laravel developers. I want to allow user to connect to one or more of these APIs:
- Google Login
- Google Calendar
- Google Drive
I have used Laravel Socialite so far, which provides clear connection to many social accounts. My issue is that through Socialite I have only one google Driver, while I need to address to different Google API from different buttons.
My .env data, connected to the config/services.php are:
GOOGLE_CLIENT_ID=1.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=XXX
GOOGLE_CALLBACK_URL=https://mysite/google/login_callback
GOOGLE_CALENDAR_CLIENT_ID=2.apps.googleusercontent.com
GOOGLE_CALENDAR_CLIENT_SECRET=YYY
GOOGLE_CALENDAR_CALLBACK_URL=https://mysite/google/calendar_callback
GOOGLE_DRIVE_CLIENT_ID=3.apps.googleusercontent.com
GOOGLE_DRIVE_CLIENT_SECRET=WWW
GOOGLE_DRIVE_CALLBACK_URL=https://mysite/google/drive_callback
Now, it is now clear to me how to manage multiple APIs from different buttons. Here some options:
- Use Socialite with unique credential entry point (google_login) from Google Console Cloud and in the callback function into the Controller I differentiate different cases (login, calendar, drive...)
- I create a different Google credential for each API into API section, I use Socialite only for login and I create/download separate package for Calendar, for Drive, etc...
So the main point is: multiple Google APIs in Laravel need to be applied with unique API credential and at Controller level I address to relative code using scopes or I have to create a separate API credential of each API, make the relevant .env keys and the manage all separately.
I hope to have been not to much blur. thanks!