403 forbidden for some youtube urls - c#

Currently I am developing an app which fetches audio url from a youtube video id.
It is working perfectly for some url and not working at all for some urls.
Even I copied in a browser to play a audio url,One url worked other didnot.
For your information I am using Mytoolkit.Multimedia to fetch audio urls.
For example-
This url works-
https://r13---sn-h557sn7y.googlevideo.com/videoplayback?ipbits=0&mn=sn-h557sn7y&mm=31&pl=24&mime=audio/mp4&id=o-ACVoF4mkT7VFETu-c1pUD-2y3fiDbqhg_AWvjzMh6rLd&gir=yes&mt=1486618643&ms=au&requiressl=yes&ip=103.6.159.152&upn=ck_2dMVCbO0&signature=C65C13CAE27021FA797E07C3C957F2106FA43F0C.542B383152E7D32AD7F5C3C386D7D7E4CCB7C846&lmt=1458210574977365&key=yt6&itag=140&keepalive=yes&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,itag,keepalive,lmt,mime,mm,mn,ms,mv,pl,requiressl,source,upn,expire&source=youtube&clen=4324664&initcwndbps=551250&ei=SgCcWKXHDM3ioAOdy6PgCA&mv=m&dur=272.230&expire=1486640298
This url does not work-
https://r9---sn-h557sn7r.googlevideo.com/videoplayback?mn=sn-h557sn7r&mm=31&key=yt6&ip=103.6.159.152&sparams=clen,dur,ei,gcr,gir,id,initcwndbps,ip,ipbits,itag,keepalive,lmt,mime,mm,mn,ms,mv,pl,requiressl,source,upn,expire&pl=24&source=youtube&dur=258.089&keepalive=yes&mv=m&gcr=in&ms=au&ei=gQCcWJyTEcS3oAPR3IjoCA&id=o-ACkoY4Axz1oHH7Ncr4llzAWZn8JoIFAtS7HTbve90Xgd&mt=1486618702&gir=yes&upn=PF_MHOBEk38&ipbits=0&mime=audio/mp4&requiressl=yes&clen=4099627&expire=1486640353&itag=140&lmt=1438240696726539&initcwndbps=551250&signature=1CDC7B591477B660AEF655DC5687F750F57C8CFF44.FB05DE5F885A99FFD0DE7B5D75AB2589C40FFF77
Also I noticed,it is not working for those whose parameter ends with signature,
I guess that does not matter.I have re-arranged parameters ,Still same error(http error 403).
Please note-Even links not working google chrome.
Is there any other ways ,where I extract audio from youtube video id.
Thanks

You may find in YouTube Data API - Errors the possible reasons why you encounter Error 403.
Based from the given link, error 403 - forbidden is basically due to a not properly authorized request. Please check and make sure that you set proper authorization or make sure that the permissions associated with the requests are sufficient.

I final built a custom library to fetch data,Problem was not with youtube links,it was with libraries I was using.

Related

Unable to play encrypted video in iframe in chrome. Firefox and edge can play the same iframes with the same URL

We are creating a video hosting site using azure. Since the videos we intend to propagate are private mixed with public, we have decided to use encryption(Widevine and Playready) and a log in system. Since we also have public videos, we provided users to create an embed URL for the videos. We a We facilitated this using a document id and a view that is publicly accessible and this view will be in the embed URL. When a request with the valid document id reaches this view, we call another view with the credentials for decrypting that video. In this view the video is played using azure media player. All this is working in most sites but for some sites especially websites created using Wix,Strikingly
and Godaddy , it shows the below error:
Encrypted Media access has been blocked because of a Feature Policy applied to the current document. See this link for more details.
I have already added the allow="encrypted-media" permission in the embed code, but of no use.
I am also getting this error code - error: videojs: 2.2.4.1 (CODE:273678337 undefined) [object Object]
Has anyone run in to a similar situation and found a solution for the same? If so please do help.

YouTube Data V3 API not recognizing localhost url for redirect uri, why?

I am trying to test out the YouTube Data API V3 to Upload a Video to YouTube in C# using the example code supplied.
I am using the OAuth2 method. I have generated a Client ID / Secret successfully.
The issue I am having is that created a standard C# MVC ASP.NET project, and every time I run it it might say for example http://localhost:5151/.
We are on a private network so I usually have to use something like ngrok to receive anything from the outside world being sent directly to my server / machine.
Anyways, where was I? So every time I run my application it says in my url box http://localhost:5151/ but when I attempt to run the code in the sample I provided above, it fails to validate me as a user because they claim that the redirect uri's I have set up in the Google API dashboard are not the same as the url being used.
So for example, in my Google API Dashboard redirect uri list I have http://localhost:5151/. But the google misdirect uri error that comes back claims that I am running on http://localhost:6163/ .
So I think wait, that must be just a fluke. So I run my application again and now in the url it again says what I would assume it should: http://localhost:5151/, but I again get the same google error_mismatch_redirect_uri error but this time with a different port: http://localhost:6621/ !!
I'm not sure what settings are on our servers but it looks like in the background my application is starting up on some random port every time and thus google thinks the redirect uri's dont match! What can I do to fix this? Am I missing something trivial here?
UPDATE:
Tried using http://localhost:8080 per their documentation. Still didn't work.
Wow, after hours of searching I found the answer here: https://stackoverflow.com/a/28794316/7010468. Apparently you have to put http://localhost/authorize/ in your list of redirect-uris...

Getting the Google search terms from a https Google search

I want to get the search terms that user typed on Google to get to my long-tail landing page (and use them on that page).
Getting the the "q" variable from the query string using the response referrer (in ASP C#) works well but only if the referring Google page was not loaded as https.
This is obviously a problem due to the fact that almost everyone is logged in to their Google accounts on their browsers all the time and, if they are, all Google pages will be automatically loaded (and redirected) to use https.
When a user (on https://www.google.com) searches for something and clicks on a search result, Google seems to redirect the user to an intermediate page that strips the request of its query string and replaces it with a different one that pretty much only contains url that the intermediate page should redirect to (i.e. the url to my long-tail landing page).
Is there any way that I can get the original search terms that were used on https://www.google.com anyway? Maybe if JavaScript could access the browser history or something similar?
Is there any way that I can get the original search terms that were used on https://www.google.com
No, the full text of the https session is secured via SSL this includes headers, urls etc. In your scenario, for security reasons browers tend to omit the referer header therefore you won't be able to access it (unless the destination URL is also secured via HTTPS). This is part of the HTTP spec - 15.1.3 Encoding Sensitive Information in URI's.
The only thing you can do is put a disclaimer on your site to say it doesn't work over https.
Since it is Google, it is not possible because there is not shared link with your website.
Once you are on HTTPS - it does not allow sending of REFERRER headers. I am sure you are aware that headers can be manipulated and cannot be trusted but, you may trust Google. However, due to privacy policy any activity done on Google by Google users are not shared by 3rd party. Link
Again, in server side languages you can find functions for HTTP Referrer but not HTTPS referrer. That is for a reason !
Unless and until you do not have a collaboration with the originating server who may create an exception in their RFC thing to allow HTTP REFERRER ONLY for your website. It isn't possible.
Hope that helps! (in moving on) :)
EDIT: Wikipedia Link See Referrer Hiding (2nd last line)
To see the referrer data you need to be either a paying google ads customer (and the visitor come via an ad-click) or have your site in HTTPS as well. Certs are cheap these days or you could use an intermediary like CloudFlare to do the SSL and have a self-signed cert on your site.
You can also see queries no matter the method used, with Google Webmaster tools.
I wrote a little about this here: http://blogs.dixcart.com/public/technology/2012/03/say-goodbye-to-keyword-tracking.html

Google ClientLogin Authorization and Google Music

I am playing around with Google Music. I'm trying to see if I can write an app that will stream my music files uploaded to Google Music. So far, I've managed to authenticate myself using ClientLogin and access the music.google.com page. However, whenever I try to access http://music.google.com/music/services/loadalltracks, the page that contains all of my tracks in JSON format, I get a 401: Unauthorized error. However, if I pass the cookies containing SID and HSID, it works and I can access the page.
Does anyone know why It doesn't work with ClientLogin, outside of Google not supporting it with Music? Have you had similiar experience with other Google Services? In the event I can't get ClientLogin to work, is there anyway to work around it, using the SID? I don't know how the HSID is generated.
Since there is no official api for Google Music, you need full SSO credentials to use those endpoints. The easiest way to do this is to emulate a browser (with eg mechanize).
The way my unofficial Google Music api accomplishes this is a bit cleaner, but more work: use clientlogin to authenticate to the Music Manager service, then upgrade those credentials using tokenauth. This isn't really a public feature, but it's described by a third party here, and by a Google design doc here. The specific endpoints you need are in my code here (in clientlogin.py and tokenauth.py).
You'll want to send u=0 and xt=[value of xt cookie] in the querystring as well. The first argument specifies which account you're using (if you're signed into multiple), and the second is a xsrf token.
Well, as far as I can tell the reason sending the SID and HSID cookies makes the request work is because you're simulating the way a normal user is accessing the service.
You can't go the regular application way because that's not supported in google music (as far as my internet research showed, there's no API for google music).
Oh, and one thing: google discourages people from using ClientLogin and instead tells people to use OAuth ("ClientLogin [is] Google's proprietary authorization API ... you should avoid using [this] service." found at http://code.google.com/apis/gdata/docs/auth/overview.html) so in the future you might want to use that. Maybe it'll even work in this case (It sends a different token from ClientLogin - OAuth token instead of an Auth token) though I doubt that.
Anyway, I hope this cleared things up.

WebRequest C# 403 Error

Okay so here's what I'm doing.
I'm making a request to a server to pull down a file.
I do this by making a WebRequest to the website the getting the response just as you usually would, although i get a 403 error saying i don't have permissions.
Problem is when i plug the URL into Google Chrome I get redirected and the file i requested comes down. I've tried the URL on other browsers and get the 403 error.
What is Google Chrome doing that allows it to bypass the 403 error? I've tried using the Google Chrome User Agent, but that doesn't help me.
Help
Possibly the web server recognizes the Chrome user agent and allows the file to be downloaded by it, but not by other user agents. Set up your WebRequest to use the same user agent strings and settings as Google Chrome - by default it might be using the IE settings.
Edit: Here's instruction from MSDN about how to set the WebRequest user agent string.
To find out the user agent of any browser, enter this into its address bar:
javascript:prompt('my user agent string is', navigator.userAgent);
The 403 status code indicates the resource you're attempting to reach is Forbidden. As in, don't ask because you're not getting it. This differs from the 401 code in that an Authorization challenge is presented before the server will confirm delivery of the resource.
While this could be programmatic configuration, this might also be explained by access restrictions on the resource as configured through the web server.
Can you verify that the downloaded resource in Google Chrome is the expected resource you're attempting to reach?
Thanks for the help. None of your answers helped me directly, but thanks for trying.
My Program was trying to pull a file off a server. I had figured out how to get around the authentication issues and finding the file on the server while using Chrome. It turns out that their web service is more advanced using user sessions.
Basically I didn't have access to the webservice commands, so all i could do is use the basic http urls to get a predefined response. The files url that i used to get the file of the server was not unique, it was dynamic depending on the webbrowser / the session. I was using the HTTPRequest object to get the HTML file so i could parse it. With the html file i parsed it to find out the dynamic ID of the file (I thought it was unique). Then I'd attach that to the end of a URL. In Chrome I would be redirected and presented with the download prompt. Problem was that I needed the webbrowser object when i wanted to pull down the file. Knowing this i used the webbrowser object to get the file ID, then used the same webbrowser object (Technically same sessions according the webserver) to pull down the file.
It's rather complicated. Basically my program is a little hack that provides functionality that the server is try block.
Hope this assisted you guys in any of your future projects.

Categories