Skip to content
This repository has been archived by the owner on Apr 3, 2021. It is now read-only.

OAuthRequest.ForProtectedResource #23

Open
najsgrgutin opened this issue Nov 4, 2020 · 0 comments
Open

OAuthRequest.ForProtectedResource #23

najsgrgutin opened this issue Nov 4, 2020 · 0 comments

Comments

@najsgrgutin
Copy link

Hello, thank you for providing this useful nuget!! However, I'm having a problem fetching user data from the twitter API. This is my code snippet:

              var client = OAuthRequest.ForProtectedResource("GET", _apiKey, _apiKeySecret, oauthToken, oauthTokenSecret);            
              client.RequestUrl = requestUrl;
              var auth = client.GetAuthorizationHeader();

Method GetAuthorizationHeader on an OAuthRequest instance throws an exception with a message: "Failed to compare two elements in the array." InnerException message: "Object reference not set to an instance of an object." and StackTrace "at OAuth.OAuthTools.<>c.b__19_1(WebParameter x, WebParameter y)\r\n at System.Collections.Generic.ArraySortHelper1.InsertionSort(T[] keys, Int32 lo, Int32 hi, Comparison1 comparer)\r\n at System.Collections.Generic.ArraySortHelper1.IntroSort(T[] keys, Int32 lo, Int32 hi, Int32 depthLimit, Comparison1 comparer)\r\n at System.Collections.Generic.ArraySortHelper1.IntrospectiveSort(T[] keys, Int32 left, Int32 length, Comparison1 comparer)\r\n at System.Collections.Generic.ArraySortHelper1.Sort(T[] keys, Int32 index, Int32 length, Comparison1 comparer)"

When I use different approach:

        var client = new OAuthRequest
        {
            Method = "GET",
            Type = OAuthRequestType.ProtectedResource,
            SignatureMethod = OAuthSignatureMethod.HmacSha1,
            ConsumerKey = _apiKey,
            ConsumerSecret = _apiKeySecret,
            Token = oauthToken,
            TokenSecret = oauthTokenSecret,
            RequestUrl = requestUrl,
            Version = "1.0a"
        };
        var auth = client.GetAuthorizationHeader();

I get the same error. I cannot identify the cause of this issue because fetching request and access token works just fine. Hope anyone can help me with this :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant