Hi, I'm using this code below. Not getting ant try/catch errors but am getting this:
"Id = 9, Status = WaitingForActivation {1}, Method = "{null}", Result = "{Not yet computed}"
I've been stuck for many hours and can't seem to figure this out. I hope someone can help or provide a good example.
My task is to get MS oAuth to return a token so I can access an API.
Thank You
Code:Public Class Tforce Inherits System.Web.UI.Page Private Sub Form1_Load(sender As Object, e As EventArgs) Handles form1.Load Dim Test = AsyncCall(Nothing) End Sub Protected Async Function AsyncCall(ByVal e As System.EventArgs) As Task Dim clientId As String = "4e502cbc-a55f-4341-a498-69cfbe19ee7b" Dim clientSecret As String = "My Secret goes here " Dim credentials = String.Format("{0}:{1}", clientId, clientSecret) Dim headerValue = Convert.ToBase64String(Encoding.UTF8.GetBytes(credentials)) Dim content = New FormUrlEncodedContent(New Dictionary(Of String, String) From { {"client_id", clientId}, {"client_secret", clientSecret}, {"grant_type", "client_crdentials"}, {"scope", "https://tffproduction.onmicrosoft.com/04cc9749-dbe5-4914-b262-d866b907756b/.default"} }) Dim requestMessage = New HttpRequestMessage(HttpMethod.Post, "https://login.microsoftonline.com/ca4f5969-c10f-40d4-8127-e74b691f95de/oauth2/v2.0/token") requestMessage.Headers.Authorization = New AuthenticationHeaderValue("Basic", headerValue) requestMessage.Content = content Dim responsemessage As HttpResponseMessage Dim client As New HttpClient Try responsemessage = Await client.SendAsync(requestMessage) Catch ex As Exception Dim showerror As String = ex.Message End Try End Function End Class




Reply With Quote
