0

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) サーバーを利用できません。

理想的には、認証キーをコピーして貼り付ける際に手動で介入する必要がないため、2 Legged Authenticator アプローチを使用することをお勧めしますが、現時点では何かを機能させることがプラスになります。

どんな助けでも感謝します!

4

2 に答える 2

0

503 エラーは通常、API クォータに達していることを示しています

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

24 時間待ってから、もう一度実行してみてください。クォータは毎日の基本で自動的にリセットされます。

さらに、移行関連の質問には google-email-migration をタグ付けし、グループの移行には google-groups-migration をタグ付けする必要があります

于 2013-02-20T17:18:00.430 に答える