Google Groups迁移C#API不起作用

本文关键字:不起作用 C#API 迁移 Groups Google | 更新日期: 2023-09-27 17:57:38

我正在尝试使用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();
}

但是这导致CCD_ 1异常。

我还尝试了以下内容:

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);
    }
}

但以CCD_ 2失败。内部异常是:

远程服务器返回错误:(503)服务器不可用。

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

感谢您的帮助!

Google Groups迁移C#API不起作用

503错误通常表示您达到了API配额

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

你会等24小时再重新运行吗?配额在日常基础上自行重置。

此外,您应该用谷歌电子邮件迁移标记您的迁移相关问题,并用谷歌组迁移

标记组迁移

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

结果,我们发现这个问题再次出现是因为示例中的"消息ID"标头的格式无效。

此拼写错误已于2013年8月12日修复。

请尝试更改来自的邮件IDNNNN@mail.samplegroup.com至<NNNN@mail.samplegroup.com>。