Changes

UBIK Graph Service

4,654 bytes added, 15:23, 10 May 2021
Created page with "The UBIK Graph Service is an Interface consisting of web service, based on .Net Core, and a Ubik Plugin. The Graph Service Client plugin manages the communication between the..."
The UBIK Graph Service is an Interface consisting of web service, based on .Net Core, and a Ubik Plugin. The Graph Service Client plugin manages the communication between the UBIK system and the Ubik Graph Service is responsible for the authentication and communication to the Microsoft Graph API. To get access to the Microsoft Graph API you must register a new App on your Microsoft Azure Portal (see: Additional Information).

= Web Service =
The Web Service exposes the following endpoints, to communicate to the Microsoft Graph API. The request must be formatted as JSON. <br/><br/>
<source lang="ini">
POST: https://<IIS host>/Authentication
</source>
'''Request Body'''<br />
<code>string clientId</code> <br />
<code>string tenantId</code> <br />
<code>string clientSecret</code> <br />
<code>NetworkCredential networkCredential</code><br />
<code>GrantType grantType </code><br />

'''GrantType'''<br/>
<code>ClientCredentials: 0</code>
<code>UsernamePasswordCredentials: 1</code>

'''Response''' <br />

<code>Data</code> contains a Token property, where the generated token is stored. <br />
<code>Message</code> Contains a GraphMessage, of the result of the request <br/><br/>

<source lang="ini">
POST: https://<IIS host>/SharePoint/File
</source>
'''Request''' <br />
The authorization header must contain the token in <Bearer token> format

The request body must contan the following properties formatted as JSON.<br/>
<code>string FilePath</code><br />
<code>string File</code><br />
<code>string Description</code><br />
<code>string SiteId</code><br />
<code>string DriveId</code><br />

'''Response''' <br/>
The Response contains the <code>GraphMessage Message</code> GraphMessage property, which contains information about the request.<br/><br/>

<source lang="ini">
PUT: https://<IIS host>/SharePoint/File
</source>

'''Request'''<br />
The authorization header must contain the token in <Bearer token> format

The request body must contan the following properties formatted as JSON.<br/>
<code>string FilePath</code><br />
<code>string NewFilePath (optional)</code><br />
<code>string File (optional)</code><br />
<code>string Description (optional)</code><br />
<code>string SiteId</code><br />
<code>string DriveId</code><br />

'''Response''' <br/>
The Response contains the <code>GraphMessage Message</code> property, which contains information about the request.<br/><br/>

==== GraphMessage ====
The GraphMessage is part of every response and contains information about the request and has the following properties:<br/>
<code>string Message</code><br />
<code>enum Status {Success: 0,Failed: 1, Unauthorized: 2}</code><br />


= UbikGraphClient Plugin =
The Plugin provides a Class, which can be instantiated and handles the communication with the service. Depending on the Authentication Flow you can instantiate the client via several constructors. This plugin will then manage the Authorization to the service for the customizer.

=== Client Credentials Flow ===

<source lang="ini">public Client(string serviceUrl, string tenantId, string cleintId, string clientSecret)</source>

=== Username/Password Flow ===
<source lang="ini">public Client(string serviceUrl, string tenantId, string cleintId, NetworkCredential networkCredential)</source>

= SharePoint =
The Client class also provides methods to create and update files on SharePoint<br />

<source lang="ini"> public GraphMessage CreateFile(string SiteId, string DriveId, string FilePath, string File, string Description)</source>
The SiteId and DriveId are defined by the Sharepoint.<br />
The FilePath is the Path of the file on the Sharepoint, including the file name and the file extension.<br />
The File is the content of the file formatted as base64.<br />
The Description is the Sharepints description and can be null.<br />
<br />

<source lang="ini">public GraphMessage UpdateFile(string SiteId, string DriveId, string FilePath, string File, string Description, string NewFilePath) </source>
The SiteId and DriveId are defined by Sharepoint.<br />
The FilePath is the Path of the file on Sharepoint, including the file name and the file extension.<br />
The File is the content of the file formatted as base64. (optional)<br />
The Description is the Sharepints description. (optional)<br />
The NewFilePath is the new file path on the SharePoint including the file name and the file extension. (optional)<br />

= Additional Information =
[https://docs.microsoft.com/en-us/graph/auth-register-app-v2 App Registration] <br/>
[https://docs.microsoft.com/en-us/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-5.0&tabs=visual-studio .Net Core on IIS]
9
edits