Skip to content

Authorization Code Grant Flow Does Not Work #40

@900008676

Description

@900008676

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");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions