Need help Requesting Authorization and refreshing Tokens in C#

I don’t know what I am doing. Here is what I have so far:

public static async Task<bool> regenerateToken()
        {
            var values = new Dictionary<string, string>
            {
               { "grant_type", "refresh_token" },
               { "refresh_token", "world" }
            };

            var content = new FormUrlEncodedContent(values);

            var response = await client.PostAsync("https://api.infusionsoft.com/token", content);

            var responseString = await response.Content.ReadAsStringAsync();

            return true;

        }

Please help.

Hello @Jared_Knowlton!

It looks like you are missing a few parts there, but C# isn’t my forte.

The OAuth flow generally works something like:

  1. User accesses Application
  2. Application redirects user to Infusionsoft OAuth authentication page, specifies redirect URI
  3. User authenticates and allows Application to access data
  4. Infusionsoft redirects to Application endpoint specified with a POST containing access tokens
  5. Application captures and stores tokens to use in the future, presents User with Application interface
  6. Application makes API calls with access token
    6a. If the access token is expired, the refresh token is used to get a new access token and refresh token, which are then stored
  7. Application periodically refreshes the refresh token, so that it doesn’t expire at the 6-month mark

Some relevant documentation for you:

1 Like

Do you know a developer that knows C# that can help me with Step 1?

I don’t have any personal recommendations, but we have listings in the Marketplace that may help.

1 Like

Hi, @Jared_Knowlton,

I don’t know the particulars of doing this in C# however, I do know the process and it looks like you’re just posting to the endpoints. So maybe my vid that walks through the process (using php) might help. Not for the sake of the language used but more for the high level particulars.

1 Like

Hi Jared!
A bit late, but I just saw it. Actually I worked pretty much with Infusionsoft and C#. I’m working on an OpenSource library for .NET Standard on GitHub. Just check it out and contact me. If you need a special implementation, I can probably help you out.
Best regards,
Stefan