【问题标题】:Google Groups Migration C# API Not WorkingGoogle Groups Migration C# API 不工作
【发布时间】:2013-02-05 14:12:12
【问题描述】:

我正在尝试使用 C# Google Groups Migration API,但运气不佳。

我有以下代码:

public static void Main(string[] args)
{
    var body =
    @"Received: by 10.143.160.15 with HTTP; Mon, 16 Jul 2007 10:12:26 -0700 (PDT)
    Message-ID: NNNN@mail.samplegroup.com
    Date: Mon, 16 Jul 2007 10:12:26 -0700
    From: ""xxx""
    To: ""xxx""
    Subject: SUBJECT
    MIME-Version: 1.0
    Content-Type: text/plain; charset=ISO-8859-1; format=flowed
    Content-Transfer-Encoding: 7bit
    Content-Disposition: inline
    Delivered-To: xxx
    This is the body of the migrated email message.";

    var bytes = ASCIIEncoding.ASCII.GetBytes(body);

    var messageStream = new MemoryStream(bytes);

    var auth = new OAuth2LeggedAuthenticator("xxx.com", "xxx", "xxx", "xxx");
    var service = new GroupsmigrationService(auth);
    service.Key = "xxx";

    var request = service.Archive.Insert("xxx", messageStream, "message/rfc822");
    request.Upload();
}

...但这会导致Invalid Credentials 异常。

我还尝试了以下方法:

public static class Program
{
    public static void Main(string[] args)
    {
        var body =
            @"Received: by 10.143.160.15 with HTTP; Mon, 16 Jul 2007 10:12:26 -0700 (PDT)
            Message-ID: NNNN@mail.samplegroup.com
            Date: Mon, 16 Jul 2007 10:12:26 -0700
            From: ""xxx""
            To: ""xxx""
            Subject: SUBJECT
            MIME-Version: 1.0
            Content-Type: text/plain; charset=ISO-8859-1; format=flowed
            Content-Transfer-Encoding: 7bit
            Content-Disposition: inline
            Delivered-To: xxx
            This is the body of the migrated email message.";

        var bytes = ASCIIEncoding.ASCII.GetBytes(body);

        var messageStream = new MemoryStream(bytes);

        // Register the authenticator.
        var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description);
        provider.ClientIdentifier = "xxx";
        provider.ClientSecret = "xxx";
        var auth = new OAuth2Authenticator<NativeApplicationClient>(provider, GetAuthorization);

        // Create the service.
        var service = new GroupsmigrationService(auth);

        service.Key = "xxx";
        var request = service.Archive.Insert("xxx", messageStream, "message/rfc822");
        request.Upload();

        Console.ReadKey();
    }

    private static IAuthorizationState GetAuthorization(NativeApplicationClient arg)
    {
        // Get the auth URL:
        // IAuthorizationState state = new AuthorizationState(new[] { TasksService.Scopes.Tasks.GetStringValue() });
        IAuthorizationState state = new AuthorizationState(new[] { "https://www.googleapis.com/auth/apps.groups.migration" });

        state.Callback = new Uri(NativeApplicationClient.OutOfBandCallbackUrl);
        Uri authUri = arg.RequestUserAuthorization(state);

        // Request authorization from the user (by opening a browser window):
        Process.Start(authUri.ToString());
        Console.Write("  Authorization Code: ");
        string authCode = Console.ReadLine();
        Console.WriteLine();

        // Retrieve the access token by using the authorization code:
        return arg.ProcessUserAuthorization(authCode, state);
    }
}

...但是失败了:Backend Error。内部异常是:

远程服务器返回错误:(503) Server Unavailable。

理想情况下,我更喜欢使用 2 Legged Authenticator 方法,因为它不需要手动干预复制和粘贴身份验证密钥,但现在让任何东西工作将是一个加分。

感谢任何帮助!

【问题讨论】:

    标签: c# api google-apps google-email-migration google-groups-migration


    【解决方案1】:

    503 错误通常表明您正在达到 API 配额

    https://developers.google.com/google-apps/groups-migration/v1/limits

    您会等待 24 小时后再尝试重新运行吗?配额会根据日常基本情况自行重置。

    此外,您应该使用 google-email-migration 标记与迁移相关的问题,并使用 google-groups-migration 标记组迁移

    【讨论】:

    • Emily:我们只运行了几次,仍然得到相同的结果。我刚刚尝试了几天没有运行它并得到以下异常: System.Exception is unhandled Message=Backend Error Source=Google.Apis 内部异常是: Message=The remote server returned an error: (503) Server Unavailable . ...这是使用 OAuth2。使用 2Legged 我得到了无效的凭据,即使我使用的技术和凭据与我用来从其他 Google API 成功读取数据的技术和凭据相同。
    【解决方案2】:

    我遇到了同样的问题,并询问了谷歌的支持团队。

    结果我们发现该问题重现是因为示例中的“Message-ID”标头格式无效。

    此错字已修正为August 12, 2013.

    请尝试将 Message-ID 从 NNNN@mail.samplegroup.com 更改为

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-26
      • 1970-01-01
      • 2016-07-09
      • 1970-01-01
      • 1970-01-01
      • 2016-12-16
      • 1970-01-01
      相关资源
      最近更新 更多