RestSharp - Authorization Header not coming across to WCF REST service

前端 未结 3 732
攒了一身酷
攒了一身酷 2021-02-04 01:30

I am trying to call a locally hosted WCF REST service over HTTPS with basic auth.

This works and the Authorization header comes thru just fine and all is happy:

3条回答
  •  旧巷少年郎
    2021-02-04 01:33

    I used milano's answer to get my REST service call to work (using GET)

        Dim client2 As RestClient = New RestClient("https://api.clever.com")
    
        Dim request2 As RestRequest = New RestRequest("me", Method.GET)
    
        request2.AddParameter("Authorization", "Bearer " & j.access_token, ParameterType.HttpHeader)
    
        Dim response2 As IRestResponse = client2.Execute(request2)
        Response.Write("** " & response2.StatusCode & "|" & response2.Content & " **")
    

    The key was making sure there was a space after the word 'Bearer' but this may apply to any type of custom token authorization header

提交回复
热议问题