I got the access token with OAUTH2 but I can't use this token when pulling the message list .how do i use the token
public function listMessages(Request $request)
{ $this->token = $request->get('oauth_token');
$thetoken = $this->token;
$client=new client;
$client->setAuthConfig('credentials.json');
$client->setAccessToken($thetoken);
$service= new Gmail($client);
$list=$service->users_messages->listUsersMessages("myemail@gmail.com");
dd($list);
}
MY SOLVED
Before using the client package;
- I installed the 'dacastro4/laravel-gmail' package
2.With this package, we can perform oAuth2 login and create tokens
- To use it, follow the instructions from the github project; laravel-gmail-github
And now we can use the token we created thanks to the package
$access=LaravelGmail::makeToken(); //token created $thetoken=$access['access_token']; $client=new Client(); $client->setAccessToken($thetoken); //token set $service=new Gmail($client);