So I have referenced the ebay.oauth.client library and I’m trying to use it to get the access token but it’s giving me an error.
An object reference is required for the non-static field, method or property ‘OAuth2Api.GetApplicationToken(OAuthEnvironment, IList)
Here is my code
private string GetAuthTokenEbay()
{
bool isTestSite = true;
var url = (isTestSite) ? "https://api.sandbox.ebay.com" : "https://api.ebay.com"
var oAuthToken = "";
CredentialUtil.Load("config.yaml");
IList<String> scopes = new List<String>()
{
url + "/oauth/api_scope/buy.marketing",
url + "/oauth/api_scope",
url + "/oauth/api_scope/sell.inventory.readonly",
url + "/oauth/api_scope/sell.inventory"
};
//String state = "current-page";
OAuthEnvironment env = (isTestSite) ? OAuthEnvironment.SANDBOX : OAuthEnvironment.PRODUCTION;
oAuthToken = OAuth2Api.GetApplicationToken(env, scopes).AccessToken;
return oAuthToken;
}
2
Answers
Ok I figured it out, at the top of my class I needed the static oauthapi like so:
then I needed to get the application token like so
in order to help all users of this kind of problem, it is usefull to give the code as below orinigating from yours…