使用客户端的oauthtoken从我的服务器上的gdrive下载文件

I have a web form which allows users to upload files to my server, I added a button for users to select files from their google drive.

After the user selects a file, I get that file id and I have an oauthtoken for that user.

I want to send this file id and oauthtoken back to my server, and make my server download the file.

I installed the google client library on my server, and trying to download the file

this is my code:

$client = new Google_Client();
$client->setAccessToken($token);
$service = new Google_Service_Drive($client);  
$file = $service->files->get($file_id);

my token is in the form of 'ya29.FgJJWfsXI8eisDeFaNcIv6RwZH4FEozeEpjOzoVI9GeQVytY6v....' but I get an error "Could not json decode the token" from the second line, what am I doing wrong?

how can I use the oauthtoken from my client side to make an authorized request to download the file?

Your token should be JSON encoded as described in GDrive Developer Documentation:

{ "web":
  { "client_id":"8.......apps.googleusercontent.com",
     "auth_uri": "https://accounts.google.com/o/oauth2/auth",
     "token_uri": "https://accounts.google.com/o/oauth2/token",       
     "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
     "client_secret": "0z......"
  }
}

I think you should reread the documentation on the OAuth flow.