【问题标题】:Generate HTTP request with OAuth access token for Vimeo API in c#在 c# 中为 Vimeo API 生成带有 OAuth 访问令牌的 HTTP 请求
【发布时间】:2016-04-02 23:17:26
【问题描述】:

我需要按照page 中的第 2 步生成对 vimeo api 的 http 请求,如下所示。

PUT https://i.cloud.vimeo.com/video/518016424
.... binary data of your file in the body ....

我已经有一个访问令牌。假设访问令牌是“qw21we34”。如何生成一个 http 请求,令牌在标头中,二进制数据在正文中。 我尝试按照建议的here 使用WebClient() 类,但我找不到通过此类请求传递OAuth 访问令牌的方法。请注意,没有具有此功能的 Vimeo api 官方库。有人可以帮忙吗?

【问题讨论】:

    标签: c# oauth vimeo vimeo-api


    【解决方案1】:

    为此,您可以使用WebClient() 类。对于身份验证,我们还需要上一个请求中的访问令牌。我从名为 vc 的 VimeoClient 对象中得到它。这取决于你自己想办法。

    WebClient wb = new WebClient();
    wb.Headers.Add("Authorization","Bearer" +vc.AccessToken);
    var file = wb.DownloadData(new Uri(myimageurl));
    var asByteArrayContent = wb.UploadData(new Uri(thumbnail_uri), "PUT", file);
    var asStringContent = Encoding.UTF8.GetString(asByteArrayContent);
    

    发送此请求后,您应该会收到一个 json 响应,说明 asStringContent 成功。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-05-27
      • 2011-09-19
      • 1970-01-01
      • 1970-01-01
      • 2011-01-19
      • 1970-01-01
      • 2012-03-27
      相关资源
      最近更新 更多