OAuth Token Not Working


(ross.m.tiktin@gmail.com) #1

I successfully retrieved an OAuth token then immediately execute the C# code below. I get this exception. What am I doing wrong?

   Response:  WebException: The remote server returned an error: (401) Unauthorized.

   HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api-sandbox.dwolla.com/");         
    request.ContentType = "application/vnd.dwolla.v1.hal+json";
    request.Accept = "application/vnd.dwolla.v1.hal+json";
    request.Headers.Add("Authorization", "Bearer " + Token.Access_token);
    var response = (HttpWebResponse)request.GetResponse();
    String responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
    return responseString;

(Spencer Hunter) #2

Hi @rtiktin, As part of this request are you specifying the request method? i.e. request.Method = "GET";

I do want to point out that we released a C# client library awhile back which has undergone some recent updates. I’d recommend taking a look at it here to see if it could be useful.


(ross.m.tiktin@gmail.com) #3

Hi Spencer,

I tried adding request.Method = “GET”; but I’m still getting:
WebException: The remote server returned an error: (401) Unauthorized.

I downloaded the C# example but can’t use it because it uses a higher version of C#.


(Spencer Hunter) #4

The only other possible issue I see here could be that Access_token should instead be access_token. Thanks for the feedback on the C# client library, we’ll see if we can update that to support a lower version of C#!


(ross.m.tiktin@gmail.com) #5

Thanks —I’ll try it. —Ross