eBay / ebay-oauth-csharp-client

eBay OAuth C# Client Library
Apache License 2.0
54 stars 40 forks source link

AppTokenCache Dictionary Update Error #2

Closed mattglet closed 4 years ago

mattglet commented 4 years ago

I'm using the following code to retrieve an Oauth token:

var oauth = new OAuth2Api();

CredentialUtil.Load(sr);

var scopes = new[]
{
    WebUtility.UrlEncode("https://api.ebay.com/oauth/api_scope"),
    WebUtility.UrlEncode("https://api.ebay.com/oauth/api_scope/buy.marketplace.insights")
};

var response = oauth.GetApplicationToken(OAuthEnvironment.PRODUCTION, scopes);

And I'm getting the following error (with the stacktrace):

System.ArgumentException: An item with the same key has already been added. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) at System.Collections.Generic.Dictionary2.Add(TKey key, TValue value) at eBay.ApiClient.Auth.OAuth2.OAuth2Api.AppTokenCache.UpdateValue(OAuthEnvironment environment, OAuthResponse oAuthResponse, DateTime expiresAt) at eBay.ApiClient.Auth.OAuth2.OAuth2Api.GetApplicationToken(OAuthEnvironment environment, IList`1 scopes)

Should there be a check here to see if the key exists first, before adding?: https://github.com/eBay/ebay-oauth-csharp-client/blob/master/ebay-oauth-csharp-client/eBay/ApiClient/Auth/OAuth2/OAuth2Api.cs#L50

mattglet commented 4 years ago

@sdhiman30 is there still active development for this library?

sdhiman30 commented 4 years ago

@mattglet I can look into this. At the same time, please feel free to submit a PR.

mattglet commented 4 years ago

Thank you @sdhiman30 ! Can you let me know when this is published to nuget?

sdhiman30 commented 4 years ago

@mattglet New version 1.0.1 has been published with the fix.