PawanOsman / ChatGPT.Net

C# library for ChatGPT using official OpenAI API

Home Page:https://www.nuget.org/packages/ChatGPT.Net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unofficial unusable

HaoDong108 opened this issue · comments

at ChatGPTUnofficial.cs line 258

  var client = new HttpClient();
        var request = new HttpRequestMessage
        {
            Method = HttpMethod.Post,
            RequestUri = new Uri($"{Config.BaseUrl}/backend-api/conversation"),
            Headers =
            {
                {"Authorization", $"Bearer {AccessToken}" }
            },
            Content = new StringContent(JsonConvert.SerializeObject(requestData))
            {
                Headers =
                {
                    ContentType = new MediaTypeHeaderValue("application/json")
                }
            }
        };
        var response = await client.SendAsync(request);

        response.EnsureSuccessStatusCode();
        var stream = await response.Content.ReadAsStreamAsync();
        var str = await new StreamReader(stream).ReadToEndAsync();  // always an empty string

Currently auth endpoint is stopped working and its patched by OpenAI, we may remove the session-token and use access-token directly for the unofficial method

Hi @PawanOsman, can you explain how the access token should be formated to use it? I am trying to set the field AccessToken from the ChatGptUnofficial to allow for the access token directly, but the ValidateToken method is returning the following error:

The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.

in line:
var decodedPayload = Encoding.UTF8.GetString(Convert.FromBase64String(tokenPart));

I wonder how I can use it in the meantime. I can also support you with the modification from session-token to access-token if you explain your strategy.