はじめに

開始方法については、以下のセクションを参照してください。

AvePoint アプリの登録

API を使用する前に、AvePoint Online Services > システム管理 > アプリ管理 にアプリを登録し、アプリに権限を付与する必要があります。登録済みアプリでは、生成されたアプリケーション (クライアント) ID で認証を実行することができます。アプリの登録方法の詳細については、AOS ユーザー ガイド を参照してください。

アクセス トークンの取得

アプリケーション (クライアント) IDを取得し、アプリケーション (クライアント) ID でアクセス トークンを取得し、Insights for Microsoft 365 Web API で認証を実行します。

アクセス トークンを取得するには、以下の情報が必要です。

要素

説明

Identity Service URL

アイデンティティ サービス URL です。

https://identity.avepointonlineservices.com

Application (Client) ID

取得したアプリケーション (クライアント) ID です。

Scope

AvePoint アプリに付与した権限です。

Insights の場合、範囲は insights.graph.readwrite.all となります。

証明書

AvePoint アプリの登録時に使用した .cer 証明書に対応する .pfx 証明書ファイルです。

 

上記の情報を使用してアクセス トークンを取得するには、先にクライアント ID と証明書を使用して JSON Web トークンを作成し、その JSON Web トークンを使用して AOS アイデンティティ サービスに定義された範囲のアクセス トークンを要求します。

以下はアクセス トークン取得の例です。

Var identityServiceUrl = {https://identity.avepointonlineservices.com};

var client = new HttpClient();

var disco = await client.GetDiscoveryDocumentAsync(identityServiceUrl);

if (disco.IsError)

{

return;

}

var tokenResponse = await client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest

{

Address = disco.TokenEndpoint,

ClientAssertion = new ClientAssertion()

{

        Type = OidcConstants.ClientAssertionTypes.JwtBearer,

        Value = CreateClientAuthJwt(disco)

},

Scope = insights.graph.readwrite.all,

}

if (tokenResponse.IsError)

{   

return;

}

return  tokenResponse.Json

private static string CreateClientAuthJwt(DiscoveryDocumentResponse response)

        {

            var clientId = {Client ID};

            var certificateThumbprint = {Certificate Thumbprint};

 

            // set exp to 5 minutes

            var tokenHandler = new JwtSecurityTokenHandler { TokenLifetimeInMinutes = 5 };

 

            var securityToken = tokenHandler.CreateJwtSecurityToken(

                // iss must be the client_id of our application

                issuer: clientId,

                // aud must be the identity provider (token endpoint)

                audience: response.TokenEndpoint,

                // sub must be the client_id of our application

                subject: new ClaimsIdentity(

                  new List<Claim> { new Claim(sub, clientId),

                  new Claim(jti, Guid.NewGuid().ToString())}),

                // sign with the private key (using RS256 for IdentityServer)

                signingCredentials: new SigningCredentials(

                  new X509SecurityKey(new X509Certificate2(LoadCertificate(certificateThumbprint))), RS256)

            );

            return tokenHandler.WriteToken(securityToken);

        }

private static X509Certificate2 LoadCertificate(string certificateThumbprint)

        {

            var store = new X509Store(StoreName.My, StoreLocation.LocalMachine);

            store.Open(OpenFlags.ReadOnly);

            var vCloudCertificate = store.Certificates.Find(

                    X509FindType.FindByThumbprint,

                    certificateThumbprint,

                    false)[0];

            return vCloudCertificate;

        }

 

*注意: 取得したトークンの有効期限は 1 時間です。有効期限が切れた場合は、トークンを再度取得する必要があります。

API に対する要求の実行

Graph ExplorerPostman、または Insights が提供する API を使用するリクエストの構築やテストに使用する他のツールを使用することができます。

Web API URL

Insights for Microsoft 365 Web API を利用する際には、Web API URL が必要です。Web API URL は、データ センターによって異なります。データ センターに合わせて Web API URL を選択してください。

データ センター

Web API URL

オーストラリア南東部 (ビクトリア)

https://graph-au.avepointonlineservices.com/insights

カナダ中部 (トロント)

https://graph-ca.avepointonlineservices.com/insights

ドイツ中西部 (フランクフルト)

https://graph-de.avepointonlineservices.com/insights

米国東部 (バージニア)

https://graph-us.avepointonlineservices.com/insights

フランス中部 (パリ)

https://graph-fr.avepointonlineservices.com/insights

西日本 (大阪)

https://graph-jp.avepointonlineservices.com/insights

韓国中部 (ソウル)

https://graph-kr.avepointonlineservices.com/insights

北ヨーロッパ (アイルランド)

https://graph-ne.avepointonlineservices.com/insights

東南アジア (シンガポール)

https://graph-sg.avepointonlineservices.com/insights

スイス北部 (チューリッヒ)

https://graph-ch.avepointonlineservices.com/insights

イギリス南部 (ロンドン)

https://graph-uk.avepointonlineservices.com/insights

米国バージニア州 (バージニア)

https://graph-gov.avepointonlineservices.com/insights

西ヨーロッパ (オランダ)

https://graph-we.avepointonlineservices.com/insights

GCP - オーストラリア南東部 (シドニー)

https://graph-gcp-au.avepointonlineservices.com/insights

GCP - 西ヨーロッパ (エームスハーフェン、オランダ)

https://graph-gcp-we.avepointonlineservices.com/insights

GCP - 日本 (東京)

https://graph-gcp-jp.avepointonlineservices.com/insights

GCP - 米国東部 (モンクス コーナー)

https://graph-gcp-us.avepointonlineservices.com/insights