1

私は Google カレンダーの単純な要件であると考えているものを持っていますが、私の人生では、それを達成するのに役立つものをオンラインで見つけることができません.

私がやりたいことは、Web ページに自分の Google アカウント (エンド ユーザーではなく) から自分のカレンダーの 1 つを表示し、イベントや予約を作成できるようにすることだけです。これができるかどうかはわかりませんが、私には非常に単純な機能のようです。

オンラインで読んだところ、Oauth2 を使用するのではなく、Calendar Service を作成してその方法で接続する必要があるようです。これは私が現在持っているコードで、問題なくサービスを作成しますが、これからカレンダーをレンダリングする方法がわかりません。適切な例がどこにも見つからないようです。

private const string SERVICE_ACCOUNT_EMAIL = "DetailsRemoved";
private const string SERVICE_ACCOUNT_PKCS12_FILE_PATH = @"DetailsRemoved";

protected void Page_Load(object sender, EventArgs e)
{
    CalendarService x = BuildService();
    //Render the Calendar somehow
}

/// <summary>
/// Build a Calendar service object authorized with the service account.
/// </summary>
/// <returns>Calendar service object.</returns>
static CalendarService BuildService()
{
    X509Certificate2 certificate =
        new X509Certificate2(HttpContext.Current.Server.MapPath(SERVICE_ACCOUNT_PKCS12_FILE_PATH),
                             "notasecret",
                             X509KeyStorageFlags.Exportable);

    var provider = new AssertionFlowClient(GoogleAuthenticationServer.Description, certificate)
    {
        ServiceAccountId = SERVICE_ACCOUNT_EMAIL,
        Scope = CalendarService.Scopes.Calendar.GetStringValue(),
    };
    var auth = new OAuth2Authenticator<AssertionFlowClient>(provider, AssertionFlowClient.GetState);

    return new CalendarService(new BaseClientService.Initializer()
    {
        Authenticator = auth
    });
}

どんな助けでもいただければ幸いです

ありがとう

4

0 に答える 0