Types/MSGraphAPI.Oauth.AuthorizationCode.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<#
    .NOTES
    ===========================================================================
     Created with: SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.135
     Created on: 2/8/2017 10:19 AM
     Eedited on: 2/16/2017
     Created by: Mark Kraus
     Organization: Mitel
     Filename: MSGraphAPI.Oauth.AuthorizationCode.ps1
    ===========================================================================
    .DESCRIPTION
        MSGraphAPI.Oauth.AuthorizationCode Type definition
#>


@{
    Name = 'MSGraphAPI.Oauth.AuthorizationCode'
    DefaultDisplayPropertySet = @(
        'AuthCodeBaseURL'
        'Success'
        'Issued'
        'IsExpired'
        'Expires'
        'NotBefore'
        'Application'
    )
    Properties = @(
        
        @{
            MemberType = 'ScriptProperty'
            MemberName = 'Success'
            Value = {
                if ($This.AuthCodeCredential.UserName -eq 'NOAUTHCODE') { return $false }
                return $True
            }
        }
        @{
            MemberType = 'ScriptProperty'
            MemberName = 'Expires'
            Value = {
                $This.Issued.AddMinutes(10)
            }
        }
        @{
            MemberType = 'ScriptProperty'
            MemberName = 'IsExpired'
            Value = {
                $now = Get-date
                if ($now -gt $this.Expires) { return $true }
                return $false
            }
        }
        @{
            MemberType = 'ScriptMethod'
            MemberName = 'GetAuthCode'
            Value = {
                try {
                    $This.AuthCodeCredential.GetNetworkCredential().password
                }
                catch {
                    $null
                }                
            }
        }
    )
}