Youtube oembed 401 unauthorized for some videos - ruby-on-rails

I'm currently facing a 401 Unauthorized error using the ruby gem "ruby-oembed" which use oEmbed and noembed libs.
I tried it directly with oembed and noembed and I got the following result
$> https://noembed.com/embed?url=https://www.youtube.com/watch?v=3xlegeyULX8
$> {"error":"401 Unauthorized","url":"https://www.youtube.com/watch?v=3xlegeyULX8"}
and you can try it with oembed here with this youtube video https://www.youtube.com/watch?v=3xlegeyULX8
I tried to check if the video is private or has different settings but I can't find any settings different with working cases.
Any idea why it could cause it?

The video you shared 3xlegeyULX8 isn't embeddable, as YouTube Data API v3 Videos: list#status.embeddable is false for this video (cf https://www.googleapis.com/youtube/v3/videos?part=status&id=3xlegeyULX8&fields=items(status/embeddable)&key=API_KEY)
status.embeddable
boolean
This value indicates whether the video can be embedded on another website.

Related

Instagram Basic Display returns media url with Bad Url Timestamp message

Integrated the Instagram Basic display API with my website. It was working fine. From last few days some of the media url throws error code 403 with the message Bad Url Timestamp(these media were working fine earlier). I have tried refreshing the access token and creating a new one but it was not of any help. Not all the media but few of them are giving this error.
The url which is giving error
https://scontent-lht6-1.cdninstagram.com/v/t51.2885-15/128209372_3881072401959620_4985839256926707810_n.jpg?_nc_cat=108&ccb=2&_nc_sid=8ae9d6&_nc_ohc=KduPs8x3j9QAX944ddk&_nc_ht=scontent-lht6-1.cdninstagram.com&oh=3917991f8e3aaffbcf5f3017a9d78f26&oe=6002114
Can anyone help? TIA!
Instagram Basic display API have been updated. We need to stop using old API and switch to use new Instagram Basic display API.
Please refer these links:
https://embedsocial.com/blog/instagram-api-changes-2020/
https://www.instagram.com/developer/

unable to get tracks for Discover Weekly rspotify gem

I was trying to get the tracks under "Discover Weekly", But it says unauthorized access.
RestClient::Unauthorized: 401 Unauthorized from /home/<user>/.rvm/gems/ruby-2.1.1#<project>/gems/rest_client-1.8.2/lib/restclient/abstract_response.rb:48:in `return!'
In the playlist i am getting "Discover weekly" but when I try to search tracks for it, its causing this error.
Any help would be great!!
The issue here is that the Discover Weekly list is private by default. Trying to access a private playlist with the gem will throw a 401. By making the playlist public and using spotifydiscover as the username, you can access the playlist via the API. For example:
RSpotify::Playlist.find('spotifydiscover', '4ri0zgl8aDgNv2zoVPbUFZ')

How to request for tracks Using the SoundCloud SDK in iOS

I Have read the soundcloud documentation, It doesn't say much on searching for a track on soundcloud. So far in my app i can get, list and search all track of a user but i cant search all of soundcloud tracks(tracks by all soundcloud users).
Thou i have seen this but don't know how to use it:
$ curl "http://api.soundcloud.com/tracks/13158665.json?client_id=YOUR_CLIENT_ID"
I got the above from
http://developers.soundcloud.com/docs/api/reference#tracks
Please how do i use this ?
Use the /tracks endpoint with the q & other parameters.
Example search:
Format JSON / Search for "Berlin" / Genres: Techno
http://api.soundcloud.com/tracks?client_id=YOURCLIENTID&q=berlin&format=json&genres=techno

Getting an invalid_scope for youtube.upload device code request

I am trying to use the Youtube data API from an app, and I'd like to just request permission to upload videos, not to manage their entire Youtube account.
When I try to request an access token for the scope https://www.googleapis.com/auth/youtube.upload, I get back an error saying it is an invalid scope. I've given the app permission to the Youtube v3 data API.
According to the v3 youtube docs, these are the supported scopes:
https://www.googleapis.com/auth/youtube - Manage your YouTube account.
https://www.googleapis.com/auth/youtube.readonly - View your YouTube account.
https://www.googleapis.com/auth/youtube.upload - Upload YouTube videos and manage your YouTube videos.
The only one of these 3 that works for me is "https://www.googleapis.com/auth/youtube".
This is the request I am attempting:
curl -d "client_id=id&scope=https://www.googleapis.com/auth/youtube.upload" https://accounts.google.com/o/oauth2/device/code
And this is the response:
{
"error" : "invalid_scope",
"error_description" : "Not authorized to request the scopes: [https://www.googleapis.com/auth/youtube.upload]",
"error_uri" : "http://code.google.com/apis/accounts/docs/OAuth2.html"
}
I am thinking that maybe this type of request just doesn't work for device codes? The youtube.upload scope request seems to work fine in the oauth2 playground.
Update: This issue has been fixed.
This scope by itself was not whitelisted for the devices. Filed a request internally.
On the other hand, as explained here, Stackoverflow is for programming questions, you can use public issue tracker for bug reports or feature requests.
Feel free to file a bug report in issue tracker to get updated on this issue.

YouTube REST API to get playlist not working for my channel?

I am trying to get all the playlist feed URLs from the YouTube channel in my iOS application.
Below is the URL to get the XML data consists of the required contents.
https://gdata.youtube.com/feeds/api/users/thenewboston/playlists?v=2
This is working fine, which results in the response of an XML with data.
But when I change this to my username nothing is retrieved. I have couple of playlists in my channel.
My Attempts:
Attempt 1:
I have googled and cross checked my channel's privacy settings which is Public in default.
Am I making any wrong? Please let me know your comments.
Attempt 2:
When I try like this in browser, http://www.youtube.com/user/myusername
getting "This channel is not available at the moment. Please try again later.".
The same url is working fine for thenewboston.
Try this
https://gdata.youtube.com/feeds/api/videos?v=2&author=USER_NAME&orderby=published
This will fetch all the user videos.
I have found the solution:
Below is the format that I have tried.
https://gdata.youtube.com/feeds/api/users/userId/playlists?v=2
But it seems there is some change in the API.
To request a feed of another user's playlists, send a GET request to the following URL. This request does not require authentication.In the URL above, you should replace the text userId with the user's YouTube user ID. For backward compatibility purposes, the API also supports having the user's YouTube username specified instead.
To find the userId in YouTube : (Follow the steps below)
Click the arrow on top right after login to your YouTube account.
Select YouTube settings.
Select the link Advanced and find the YouTube User Id there.
Reference : YouTube API v.2.0

Resources