duanqin7791 2015-10-24 15:46
浏览 83

使用客户端的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?

  • 写回答

1条回答 默认 最新

  • dpgkg42484 2015-10-26 22:14
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了