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

[BUG] Request was unsuccessful [403] #84

Open
NguyenVuNguyenPhys opened this issue May 29, 2024 · 7 comments
Open

[BUG] Request was unsuccessful [403] #84

NguyenVuNguyenPhys opened this issue May 29, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@NguyenVuNguyenPhys
Copy link

TikTokLiveSharp.Client.HTTP.TikTokHttpRequest.GetContent () (at ./Library/PackageCache/dev.vanhoof.tiktokliveunity@18ae546fb8/TikTokLiveSharp/Client/HTTP/TikTokHttpRequest.cs:255)
TikTokLiveSharp.Client.HTTP.TikTokHttpRequest.Get () (at ./Library/PackageCache/dev.vanhoof.tiktokliveunity@18ae546fb8/TikTokLiveSharp/Client/HTTP/TikTokHttpRequest.cs:185)
TikTokLiveSharp.Client.HTTP.TikTokHttpClient.GetRequest (System.String url, System.Collections.Generic.IDictionary2[TKey,TValue] parameters) (at ./Library/PackageCache/dev.vanhoof.tiktokliveunity@18ae546fb8/TikTokLiveSharp/Client/HTTP/TikTokHTTPClient.cs:220) TikTokLiveSharp.Client.HTTP.TikTokHttpClient.GetJObjectFromWebcastApi (System.String path, System.Collections.Generic.IDictionary2[TKey,TValue] parameters) (at ./Library/PackageCache/dev.vanhoof.tiktokliveunity@18ae546fb8/TikTokLiveSharp/Client/HTTP/TikTokHTTPClient.cs:93)
TikTokLiveSharp.Client.TikTokBaseClient.FetchRoomInfo (System.Collections.Generic.IDictionary2[TKey,TValue] parameters) (at ./Library/PackageCache/dev.vanhoof.tiktokliveunity@18ae546fb8/TikTokLiveSharp/Client/TikTokBaseClient.cs:698) Rethrow as FailedFetchRoomInfoException: Failed to fetch room info from WebCast, see stacktrace for more info. UnityEngine.Debug:LogException(Exception, Object) TikTokLiveSharp.Debugging.Debug:LogException(Exception, Object) (at ./Library/PackageCache/dev.vanhoof.tiktokliveunity@18ae546fb8/TikTokLiveSharp/Debugging/Debug.cs:84) TikTokLiveSharp.Client.<FetchRoomInfo>d__54:MoveNext() (at ./Library/PackageCache/dev.vanhoof.tiktokliveunity@18ae546fb8/TikTokLiveSharp/Client/TikTokBaseClient.cs:706) System.Runtime.CompilerServices.AsyncTaskMethodBuilder1:SetException(Exception)
TikTokLiveSharp.Client.HTTP.d__7:MoveNext() (at ./Library/PackageCache/dev.vanhoof.tiktokliveunity@18ae546fb8/TikTokLiveSharp/Client/HTTP/TikTokHTTPClient.cs:94)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder1:SetException(Exception) TikTokLiveSharp.Client.HTTP.<GetRequest>d__13:MoveNext() (at ./Library/PackageCache/dev.vanhoof.tiktokliveunity@18ae546fb8/TikTokLiveSharp/Client/HTTP/TikTokHTTPClient.cs:220) System.Runtime.CompilerServices.AsyncTaskMethodBuilder1:SetException(Exception)
TikTokLiveSharp.Client.HTTP.d__24:MoveNext() (at ./Library/PackageCache/dev.vanhoof.tiktokliveunity@18ae546fb8/TikTokLiveSharp/Client/HTTP/TikTokHttpRequest.cs:185)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder1:SetException(Exception) TikTokLiveSharp.Client.HTTP.<GetContent>d__29:MoveNext() (at ./Library/PackageCache/dev.vanhoof.tiktokliveunity@18ae546fb8/TikTokLiveSharp/Client/HTTP/TikTokHttpRequest.cs:267) System.Runtime.CompilerServices.AsyncTaskMethodBuilder1:SetResult(HttpResponseMessage)
TikTokLiveSharp.Client.HTTP.d__28:MoveNext() (at ./Library/PackageCache/dev.vanhoof.tiktokliveunity@18ae546fb8/TikTokLiveSharp/Client/HTTP/TikTokHttpRequest.cs:242)
UnityEngine.UnitySynchronizationContext:ExecuteTasks() (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/UnitySynchronizationContext.cs:107)

@NguyenVuNguyenPhys NguyenVuNguyenPhys added the bug Something isn't working label May 29, 2024
@slambingo
Copy link

Same here...

@1fini
Copy link

1fini commented Jun 25, 2024

Same here. It seems like the endpoints changed

@nicatjava
Copy link

Why it always get the same error? Nobody from administration not have any issue for this error? :(

@ronikurnia1
Copy link

ronikurnia1 commented Jul 5, 2024

In my case it gets 403 error when make http request to: https://webcast.tiktok.com/webcast/gift/list.....
So, on TikTokHttpRequest.cs file I changed the GetResponseMessage method to use new instance of HttpClient and it solves the issue:

private async Task<HttpResponseMessage> GetResponseMessage()
{
    if (sent)
        throw new InvalidOperationException("Requests should not be reused");
    if (query != null)
        request.RequestUri = new Uri($"{request.RequestUri.AbsoluteUri}?{query}");

    // Start Hack
    if (request.RequestUri.AbsoluteUri.Contains("gift"))
    {
        HttpResponseMessage response = await new HttpClient().SendAsync(request);
        request.Dispose();
        sent = true;
        return response;
    }
    else
    {
        HttpResponseMessage response = await client.SendAsync(request);
        request.Dispose();
        sent = true;
        return response;
    }
    // End of Hack
}

@fanyqe
Copy link

fanyqe commented Jul 5, 2024

@ronikurnia1 I did it and it doesn't work.

@ronikurnia1
Copy link

@fanyqe not sure if your case same as mine.
In which http request endpoint do you get the 403 error code?

@78lethanhtrung
Copy link

if ((int)response.StatusCode == 429) // TooManyRequests
{
if (response.Headers.TryGetValues("RateLimit-Reset", out IEnumerable rateHeaders))
{
TimeSpan span = TimeSpan.FromSeconds(long.Parse(rateHeaders.First()));
throw new HttpRequestException($"[{(int)response.StatusCode}] Signing Rate Limit Reached. Try again in {span:mm\:ss}.");
}
else
{
throw new HttpRequestException($"[{(int)response.StatusCode}] Signing Rate Limit Reached.");
}
}
else if ((int)response.StatusCode == 403) // Forbidden
{
throw new SignConnectionException("Access forbidden. Please check your API key and permissions.");
}
else if ((int)response.StatusCode == 502) // Bad Gateway
{
throw new HttpRequestException($"[{(int)response.StatusCode}] Signing Server not reachable.");
}
else if ((int)response.StatusCode == 503) // Unavailable
{
throw new HttpRequestException($"[{(int)response.StatusCode}] Signing Server unavailable.");
}
else
{
throw new HttpRequestException($"Signing request was unsuccessful [{(int)response.StatusCode}].");
}

       **please add **
            else if ((int)response.StatusCode == 403) // Forbidden
            {
                throw new SignConnectionException("Access forbidden. Please check your API key and permissions.");
            }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants