GOOGLE GMAİL API MESSAGE LIST PHP Request is missing required authentication credential

Viewed 44

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;

  1. I installed the 'dacastro4/laravel-gmail' package

2.With this package, we can perform oAuth2 login and create tokens

  1. To use it, follow the instructions from the github project; laravel-gmail-github
  1. 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);
    
0 Answers
Related