Public/FlyConnectApi.ps1
<#
.SYNOPSIS Connect to Fly Public API .DESCRIPTION Connect to Fly Public API .PARAMETER Url The public API URL varies with your data center, you can find it in Fly user guide. .PARAMETER ClientId The application (client) ID you have retrieved from AvePoint Online Service App registrations. .PARAMETER Certificate The corresponding .pfx certificate file of the .cer certificate you used while registering the AvePoint app. .OUTPUTS None #> function Connect-Fly { [CmdletBinding()] Param( [Parameter(Mandatory = $true)] [String] ${Url}, [Parameter(Mandatory = $true)] [String] ${ClientId}, [Parameter(Mandatory = $true)] [Alias("Cert")] [System.Security.Cryptography.X509Certificates.X509Certificate2] ${Certificate} ) PROCESS { $IdentityServiceUri = 'https://identity.avepointonlineservices.com' if ($Url -eq 'https://graph-gov.avepointonlineservices.com/fly') { $IdentityServiceUri = 'https://identity-gov.avepointonlineservices.com' } elseif ($Url.StartsWith('https://graph-public.sharepointguild.com/')) { $IdentityServiceUri = 'https://identity-public.sharepointguild.com' } $Token = Get-IdentityServiceToken -IdentityServiceUri $IdentityServiceUri -Scope fly.graph.readwrite.all -ClientId $ClientId -Cert $Certificate $Configuration = Get-FlyConfiguration $Configuration["BaseUrl"] = $Url $Configuration["AccessToken"] = $Token } } <# .SYNOPSIS Disconnect from Fly Public API .DESCRIPTION Disconnect from Fly Public API .OUTPUTS None #> function Disconnect-Fly { [CmdletBinding()] Param() PROCESS { $Configuration = Get-FlyConfiguration $Configuration["BaseUrl"] = $null $Configuration["AccessToken"] = $null } } |