0
我有一個網站,允許用戶使用v2 API將我們系統中的日曆與Outlook日曆同步。Outlook API在控制檯應用程序中使用刷新令牌
當用戶點擊我們的Web應用程序上的按鈕時,我們收到刷新令牌並將其存儲在我們的數據庫中,所有一切正常。
我們有一個控制檯應用程序被設置爲定期運行以同步用戶,因此他們不需要點擊按鈕。
當我試圖隨時調用API時,我等待響應,控制檯應用程序立即關閉。
以下是從用戶日曆中獲取事件的代碼。應用程序在「暗淡迴應」行上關閉。
Public Shared Async Function FetchEventList(CalendarID As String, StartDate As String, EndDate As String, Token As String) As Task(Of EventListResponse)
Dim EventResposne = New EventListResponse()
Try
Dim data As String = Token
Dim baseUri As String = Convert.ToString("https://outlook.office.com/api/v2.0/me/calendars/") & CalendarID & "/calendarview?startDateTime=" & StartDate & "&endDateTime=" & EndDate
Dim client = New HttpClient()
client.DefaultRequestHeaders.Authorization = New System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", Convert.ToString("=") & data)
Dim response = Await client.GetAsync(baseUri)
Dim result = Await response.Content.ReadAsStringAsync()
EventResposne = Newtonsoft.Json.JsonConvert.DeserializeObject(Of EventListResponse)(result)
Catch ex As Exception
End Try
Return EventResposne
End Function
我錯過了什麼,我該如何解決它?
任何幫助,將不勝感激。