HttpService HTTP Error 403

Recently, I’ve been trying to use the Youtube Subscriber API
Code:

---- ROBLOX SERVICES ----
local HttpService = game:GetService("HttpService")

---- PRIVATE VARIABLES ----
local MAX_RESULTS_PER_PAGE = 50
local TARGET_CHANNEL_ID = "" -- YouTube channel id player is supposed to be subscribed to
local API_KEY = "" -- Your API Key

---- URL'S ----
local URL = "https://youtube.googleapis.com/youtube/v3/subscriptions?part=snippet&channelId=%s&maxResults=%d&key=%s"
local NEXT_PAGE_URL = "https://youtube.googleapis.com/youtube/v3/subscriptions?part=snippet&channelId=%s&maxResults=%d&pageToken=%s&key=%s"



---- PRIVATE FUNCTIONS ----
function get_channel_subscriptions(channelId, pageToken)
	local URL = pageToken and string.format(NEXT_PAGE_URL, channelId, MAX_RESULTS_PER_PAGE, pageToken, API_KEY) or string.format(URL, channelId, MAX_RESULTS_PER_PAGE, API_KEY)

	local success, channelSubscriptions = pcall(function()
		return HttpService:GetAsync(URL)
	end)

	if (success) then
		return HttpService:JSONDecode(channelSubscriptions)
	else
		warn(channelSubscriptions) -- error
		return nil
	end
end


function get_page_numbers_left(channelSubData)
	local pages = 0

	local pageInfo = channelSubData.pageInfo
	local totalResults = pageInfo.totalResults
	local resultsPerPage = pageInfo.resultsPerPage

	if (not channelSubData.nextPageToken) then
		return pages
	end

	pages = tostring((totalResults - #channelSubData.items) / resultsPerPage)
	if (string.find(pages, ".")) then
		pages = tonumber(string.split(pages, ".")[1]) + 1
	end	

	return pages
end


function check_if_subbed_to_channel(subData, targetChannelId)
	assert(typeof(targetChannelId) == "string", "targetChannelId must be of type [string]")

	for _, v in pairs(subData) do
		if (v == targetChannelId) then
			return true
		end
	end
	return false
end


---- RETURN FUNCTION ----
return function(channelId)
	local channelsSubscribedTo = {}
	local pageToken = nil
	local channelSubs = get_channel_subscriptions(channelId)

	if (channelSubs) then
		local pagesRemaining = get_page_numbers_left(channelSubs)

		for _, v in pairs(channelSubs.items) do
			if (v and v.snippet) then
				table.insert(channelsSubscribedTo, v.snippet.resourceId.channelId)
			end
		end

		if (pagesRemaining) then
			pageToken = channelSubs.nextPageToken
			for i = 1, pagesRemaining do
				local pageChannelSubs = get_channel_subscriptions(channelId, pageToken)

				if (pageChannelSubs and pageChannelSubs.items and pageChannelSubs.nextPageToken) then
					for _, v in pairs(pageChannelSubs.items) do
						if (v and v.snippet) then
							table.insert(channelsSubscribedTo, v.snippet.resourceId.channelId)
						end
					end
					pageToken = pageChannelSubs.nextPageToken
				elseif (not channelsSubscribedTo) then
					warn("Failed to retrieve channel subscription info")
					return false
				end
			end
		end

		return check_if_subbed_to_channel(channelsSubscribedTo, TARGET_CHANNEL_ID)
	end
	warn("channel sub info has failed to load!")
	return false
end

However, the pcall returns a Http Error 403, I’ve seen others set game to public, enable api services, allow http requests, all of which did not work for me. If anyone knows how to fix this, or what is wrong, as this module is very old, I tried manually going to the google api on my web browser and I got the same 403 error. I followed the exact instructions on the original post, but it is 2 years old, so if anyone knows of a better way to check for a player’s subscribers like bubble gum simulator or strucid, please reply.

1 Like

A 403 HTTP Server error represents that your request went through; however it refuses to accept or authorize the request.

So basically YT or Google api blocked roblox’s requests, so you’ll have to use a proxy API to get around that. The only one that I know of is for webhooks, but I’m sure there’s a proxy for it out there.

Would I get a proxy link from any web proxy and use http get there?

Also, I tried to access the link on my browser and it was blocked aswell

Well the proxy has to be made to send requests to that platform, for example:
https://hooks.hyra.io <— Using this turns a roblox request so it can send a request to discord.

It’s probably because Youtube made it so only Youtube or Domains owned by it can use that API. Most likely cause it probably got spammed. So It probably isn’t going to be entirely possible anymore, unless you have a website/proxy that YT and Google API accept.

But that would mean google apis are only accessible from websites that aren’t banned and you have to get it there??

On C#, someone used this
System.Net.WebProxy

I don’t know for sure what authorization is required to use Youtube’s API, I’m just theorizing that it most likely only accepts whitelisted domains.

Wait, does that mean bubble gum simulator and strucid don’t have this anymore?

Wait, did you fill out the API_KEY variable, and TARGET_CHANNEL_ID key?

Yes, I followed everything on the post

I just didn’t think it’d be smart giving out api keys like that, i don’t know

Then I’m assuming that YT might’ve just changed the authorization needed for their API. I wish I knew a bit more man.

I’m sorry I wasn’t able to help you out with this, I hope your able to find out the answer. But I’d say the chances that YT accepts requests from roblox is probably less than 45% sadly.