I'm trying to connect to StackExchange API using OAuth. So far i've been able to get a token and retrive data that does not require authentication. When i try do query that uses the authentication, i'm getting error 400 - Bad request. Heres the code:
Dim Key As String = "(app_key)"
Dim RequestURL As String = "https://api.stackexchange.com/2.2/me/questions?access_token=" & Token & "key=" & Key & "&order=desc&sort=activity&site=stackapps"
Dim Handler As HttpClientHandler = New HttpClientHandler()
If Handler.SupportsAutomaticDecompression Then
Handler.AutomaticDecompression = DecompressionMethods.GZip Or DecompressionMethods.Deflate
End If
Dim HttpClient As HttpClient = New HttpClient(Handler)
Dim query = Await HttpClient.GetAsync(RequestURL)
If query.IsSuccessStatusCode = True Then
'(query.Content.ReadAsStringAsync())
End If
Tried using only key, only access token, or none in the request, but received the same error. Also tried adding "OAuth" header and "access_token":
HttpClient.DefaultRequestHeaders.Authorization = New AuthenticationHeaderValue("OAuth", Token)
HttpClient.DefaultRequestHeaders.Authorization = New AuthenticationHeaderValue("access_token", Token)
Any help appreciated.