FunctionsPublic/Get-ProxsysGraphAuthenticationInfo.ps1

<#
.SYNOPSIS
Get Proxsys Graph authentication information
.DESCRIPTION
Get Proxsys Graph authentication information based on the OpenID Configuration metadata file
#>

function Get-ProxsysGraphAuthenticationInfo
{
    [cmdletbinding()]
    param ( 
        [string]$authenticationEndpoint
    )

    process
    {
        if($authenticationEndpoint.Length -eq 0)
        {
            Write-Error "Invalid input received. Please specify all parameters in order to use this function."
            return $null
        }

        Write-Debug "Using '$($authenticationEndpoint)' as authentication endpoint."
        
        $metadataResponse = Invoke-RestMethod -Method GET -Uri "$($authenticationEndpoint)/.well-known/openid-configuration"
        $RequestedDate = Get-Date

        Write-Debug "Response retrieved from token endpoint with $($metadataResponse.Length) bytes length."
        
        #
        # Construct 'Meta Data' object
        #
        @{
            Issuer = $metadataResponse.issuer
            AuthorizationEndpoint = $metadataResponse.authorization_endpoint
            TokenEndpoint = $metadataResponse.token_endpoint
            UserInfoEndpoint = $metadataResponse.userinfo_endpoint
            EndSessionEndpoint = $metadataResponse.end_session_endpoint
            CheckSessionIfram = $metadataResponse.check_session_iframe
            RevocationEndpoint = $metadataResponse.revocation_endpoint
            IntrospectionEndpoint = $metadataResponse.introspection_endpoint
            DeviceAuthorizationEndpoint = $metadataResponse.device_authorization_endpoint
            ScopesSupported = $metadataResponse.scopes_supported
            ClaimsSupported = $metadataResponse.claims_supported
            GrantTypesSupported = $metadataResponse.grant_types_supported
            ResponseTypesSupported = $metadataResponse.response_types_supported
            ResponseModesSuppored = $metadataResponse.response_modes_supported
            TokenEndpointAuthMethodsSupported = $metadataResponse.token_endpoint_auth_methods_supported
            SubjectTypesSupported = $metadataResponse.subject_types_supported
            IdTokenSigningAlgValuesSupported = $metadataResponse.id_token_signing_alg_values_supported
            CodeChallengeMethodsSupported = $metadataResponse.code_challenge_methods_supported
            LastRequestDate = $RequestedDate
            Session = $Session
            GUID = [guid]::NewGuid()
        }
    }
}