@@ -7,21 +7,22 @@ Attribute VB_GlobalNameSpace = False
7
7
Attribute VB_Creatable = False
8
8
Attribute VB_PredeclaredId = False
9
9
Attribute VB_Exposed = True
10
- Implements IAuthenticator
11
10
''
12
- ' Google Authenticator v1 .0.0
11
+ ' Google Authenticator v2 .0.0
13
12
' (c) Tim Hall - https://github.com/timhall/Excel-REST
14
13
'
15
14
' Custom IAuthenticator for "installed application" authentication for Google APIs
16
15
'
17
16
' - https://developers.google.com/accounts/docs/OAuth2#installed
18
17
' - https://developers.google.com/accounts/docs/OAuth2InstalledApp
19
18
'
20
- ' @dependencies
19
+ ' @implements IAuthenticator
21
20
22
21
' @license: MIT (http://www.opensource.org/licenses/mit-license.php)
23
22
'
24
23
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '
24
+ Implements IAuthenticator
25
+ Option Explicit
25
26
26
27
Private Const AuthorizationUrl As String = "https://accounts.google.com/o/oauth2/auth"
27
28
Private Const RedirectUri As String = "urn:ietf:wg:oauth:2.0:oob"
@@ -111,6 +112,10 @@ End Property
111
112
' Public Methods
112
113
' ============================================= '
113
114
115
+ ''
116
+ ' Setup authenticator
117
+ ' --------------------------------------------- '
118
+
114
119
Public Sub Setup (ClientId As String , ClientSecret As String )
115
120
Me.ClientId = ClientId
116
121
Me.ClientSecret = ClientSecret
@@ -148,21 +153,46 @@ Public Sub Logout()
148
153
Me.Token = ""
149
154
End Sub
150
155
151
- Private Sub IAuthenticator_BeforeExecute (Request As RestRequest )
156
+ ''
157
+ ' Hook for taking action before a request is executed
158
+ '
159
+ ' @param {RestClient} Client The client that is about to execute the request
160
+ ' @param {RestRequest} Request The request about to be executed
161
+ ' --------------------------------------------- '
162
+
163
+ Private Sub IAuthenticator_BeforeExecute (ByVal Client As RestClient , ByRef Request As RestRequest )
152
164
If Me.ApiKey <> "" Then
153
165
Request.AddQuerystringParam "key" , Me.ApiKey
154
166
Else
155
167
Request.AddHeader "Authorization" , "Bearer " & Me.Token
156
168
End If
157
169
End Sub
158
170
159
- Private Sub IAuthenticator_HttpOpen ( _
160
- Http As Object , _
161
- Request As RestRequest , _
162
- BaseUrl As String , _
163
- Optional UseAsync As Boolean = False )
171
+ ''
172
+ ' Hook for taking action after request has been executed
173
+ '
174
+ ' @param {RestClient} Client The client that executed request
175
+ ' @param {RestRequest} Request The request that was just executed
176
+ ' @param {RestResponse} Response to request
177
+ ' --------------------------------------------- '
178
+
179
+ Private Sub IAuthenticator_AfterExecute (ByVal Client As RestClient , ByVal Request As RestRequest , ByRef Response As RestResponse )
180
+
181
+ End Sub
182
+
183
+ ''
184
+ ' Hook for overriding standard http open (used for HTTP Basic)
185
+ '
186
+ ' @param {MSXML2.IXMLHTTPRequest} http
187
+ ' @parma {RestClient} Client The client that is about to open request
188
+ ' @param {RestRequest} Request The request about to be opened
189
+ ' @param {String} BaseUrl
190
+ ' @param {Boolean} [useAsync=False]
191
+ ' --------------------------------------------- '
192
+
193
+ Private Sub IAuthenticator_HttpOpen (ByRef Http As Object , ByVal Client As RestClient , ByRef Request As RestRequest , BaseUrl As String , Optional UseAsync As Boolean = False )
164
194
165
- ' Perform standard http open
195
+ ' Perform standard http open
166
196
Http.Open Request.MethodName(), Request.FullUrl(BaseUrl), UseAsync
167
197
End Sub
168
198
0 commit comments