Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

afrasiyabhaider's avatar

How to work with google classroom api in Laravel

I want to work with google classroom api and get classroom data (Course Material : Lectures/Assignments/etc) from google classroom api. How can i do that?

I've already tried google classroom documentation but it is way too complex

0 likes
9 replies
afrasiyabhaider's avatar

Thank you @devfrey , But I've already gone through this documentation. I don't get what should i write in driver parameter

return Socialite::driver(' here??? ')->redirect();

afrasiyabhaider's avatar

I want to work with Google Classroom API, so shouldn't I work with Socilaite? Is there anything else that i can work with?

devfrey's avatar

@AFRASIYABHAIDER - Of course you don't need Socialite. Google's library has all authentication built it. If you insist on using Socialite, you'll have to exchange tokens with Google's library.

devfrey's avatar

@AFRASIYABHAIDER - No thanks. Feel free to post further questions here, so other people can assist as well.

Just a tip, if you want assistance be sure to include as many details as you can, and narrow your problem down as much as possible.

afrasiyabhaider's avatar

Ok I am working with API, when I stuck anywhere then I'll post it here. Thanks for the help @

afrasiyabhaider's avatar
Level 2

I've found how to connect with google classroom API

1- go to "https://developers.google.com/classroom/quickstart/php" and enable classroom API

2- Open terminal in VS code and write command "composer require google/apiclient:^2.0"

3- Go to "\vendor\google\apiclient\src\Google\Client.php" and setup API

4- Set values in Client.php class constructor (Line 92) e.g client_id, client_secret etc

5- Create a controller and write the following code in the Index function

$client = new Google_Client();

    $service = new Google_Service_Classroom($client);

    dd($service); // display data - check if service is created or not
ysaludes's avatar

For future readers, I strongly suggest to avoid editing content in /vendor/* since all of this will be erased at every opportunity by composer. Prefer declaring a new client as descripber in step 5 by OP, and set the variables from your code. create .env variables, and use env() to call them.

$client = new Google\Client(); $client->setApplicationName("Client_Library_Examples"); $client->setDeveloperKey("YOUR_APP_KEY");

or better, use a service account where credentials are stored in a simple .json file on the project.

https://github.com/googleapis/google-api-php-client

Please or to participate in this conversation.