Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authorization Code Grant Flow Does Not Work #40

Open
900008676 opened this issue Jan 21, 2024 · 1 comment
Open

Authorization Code Grant Flow Does Not Work #40

900008676 opened this issue Jan 21, 2024 · 1 comment

Comments

@900008676
Copy link

I followed the instructions listed in the readme. I confirmed authorization URL is correct and matched what I see in the API Explorer. I am able to get a user token using the User Tokens section of eBay Developers website. However, the SDK is returning, "invalid_grant...the provided authorization grant code is invalid or was issue to another client". Here is the C# .NET 8 console application code. What am I doing wrong or it there a bug?

using eBay.ApiClient.Auth.OAuth2;
using eBay.ApiClient.Auth.OAuth2.Model;

CredentialUtil.Load("ebay-config.yaml");

OAuth2Api ebayApi = new OAuth2Api();

string userAuthorizationUrl = ebayApi.GenerateUserAuthorizationUrl(OAuthEnvironment.PRODUCTION, new List<string>()
{
    "https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly"
}, null);

if (!string.IsNullOrEmpty(userAuthorizationUrl))
{
    Console.WriteLine($"Authorization Url: {userAuthorizationUrl}");
    OAuthResponse response = ebayApi.ExchangeCodeForAccessToken(OAuthEnvironment.PRODUCTION, userAuthorizationUrl);
    if (response != null && response?.AccessToken == null)
    {
        Console.WriteLine($"Error Getting Token: {response?.ErrorMessage}");
    }
    else
    {
        Console.WriteLine($"Access Token: {response?.AccessToken}");
    }
}
else
{
    Console.WriteLine("Failed to get authorization URL");
}
@yunits
Copy link

yunits commented Feb 6, 2024

Without reviewing your code: I guess it is not compatible with .NET 8. Did you try to downgrade to .NET 6 for testing purposes?
Otherwise just download and copy classes into your project until this repo gets updated.

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

No branches or pull requests

2 participants