Getting an invalid_scope for youtube.upload device code request - youtube-api

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.

Related

My app is not able to send message to Teams channel using graph api

I am trying to send message to teams channel using graph api. I am able to send the messages using my personal(user) tokens but not able to do it using an app which I have registered in Azure portal. My app also got access to protected apis from Microsft Teams.
Attaching the screen shot of app permissions and code snippet on how I am getting tokens.
app permissions
Code snippet to get tokens
One thing I noticed, when I decoded the the tokens I am getting, that roles in tokens only shows application permissions("Teamwork.Migrate.All") and it doesn't show delegated permissions("ChannelMessage.Read.All","ChannelMessage.Send","Teamwork.Migrate.All").
Below are the error message I am getting.
While doing get request to https://graph.microsoft.com/v1.0/teams/{teams_id}/channels/{channel_id}/messages
one of 'ChannelMessage.Read.All' or 'ChannelMessage.Read.Group' when using resont. Roles on the request 'Teamwork.Migrate.All' and resource specific consent g request ''", 'innerError': {'date': '2021-07-04T14:27:41', 'request-id': '8c1f-e345bf15da7b', 'client-request-id': '8c1fffc2-c94d-4d5b-a81d-e345bf15da7b'}}}
While doing post request to https://graph.microsoft.com/v1.0/teams/{teams_id}/channels/{channel_id}/messages/{message-id}/replies
{'error': {'code': 'Unauthorized', 'message': 'Unauthorized', 'innerError': {'d4:26:47', 'request-id': '44fe99be-1ed8-4505-a3e7-a88ce934e3f8', 'client-request8-4505-a3e7-a88ce934e3f8'}}}
You are currently using Get access without a user(Application permission). Application permissions are only supported for migration. Instead you should try delegated flow: Get access on behalf of a user. Please go though the documentation and you can try it using Postman or Fiddler.
You can also try Get started with Microsoft Graph and Python tutorial which shows fetching calendar information using Graph APIs.

How to get followers list from Twitter?

I am trying to call following Twitter's API to get a list of followers for a user.
http://api.twitter.com/1.1/followers/ids.json?cursor=-1&screen_name=username
And I am getting this error message in response.
{
code = 215;
message = "Bad Authentication data";
}
I can't seem to find the documentation related to this error code. Anyone has any idea about this error?
Your request lacks authentication data. I got that error when I simply clicked on http://api.twitter.com/1.1/followers/ids.json?cursor=-1&screen_name=username. This is not the way to access twitter API.
Create a Twitter app from https://apps.twitter.com/. Then, try using a Twitter API Library to access REST API. If you are comfortable with using ruby apps on command line interface check out https://github.com/sferik/t. Set it up and then try t followers [USER] for listing all followers of USER.
You will have to use OAuth. More info can be found on Twitter website. Here: https://dev.twitter.com/oauth
This error is coming because your Twitter developers account is not approved. Now-a-days you can't make app without getting your developers account approved from Twitter.
To make an app, you need to contact Twitter and apply for developers account. If you are lucky engough, you will get approval although this process may take months.
If you just need the data, go for third party services like followersanalysis[dot]com, birdsonganalytics[dot]com

Youtube Data API - How to avoid Google OAuth redirect URL authorization

Requirement: I am trying to upload videos to my Youtube channel through Youtube Data API for Java. The request is sent from a war file hosted on tomcat container.My application is not for external users and I only use it to upload my own generated videos. With the help of the api documentation and sample youtube code snippets, I have successfully managed to post video on youtube.
Problem: The issue is that whenever I try to run the code, I get prompted for
Please open the following address in your browser:
https://accounts.google.com/o/oauth2/auth?client_id=&redirect_uri=http://localhost:8080/Callback&response_type=code&scope=https://www.googleapis.com/auth/youtube.upload
Since I run this code on a remote server, it is not possible for me to always open this URL on the browser. Since I have registered my web app in Google Console, and got a pair of Client ID and Secret and a JSON file, so Youtube must allow me to publish videos by default to atleast my channel, isin't it?
I have used the Auth.java file(provided in youtube java code samples) and the following code is where this thing happens.
// Authorize.
return new AuthorizationCodeInstalledApp(flow, localReceiver).authorize("user#.com");
LocalServerReceiver localReceiver = new LocalServerReceiver.Builder().setPort(8080).build();
Please help here as this is really eating up a lot of my development time.
You should only need to authenticate your code once. When your code is authenticated you get a refresh token back. the refresh token will then allow you to get a new access token the next time your code runs.
There is no service account authentication for the YouTube api. Your code has to be authenticated by you the first time in order to get that refresh token.
I am not a java programmer but from a quick check of the documentation it looks quite similar to what I do in.net. You need to create a datastore to to store the first refreshh token then you should be able to run your code in the future with out needing to authenticate it again.

How to fetch the processingDetails,fileDetails,suggestions information from the youtube api

I am unable to fetch the processingDetails,fileDetails,suggestions information from the youtube api call. I had used API key to fetch these details but it's not working
First I tried this API Call mentioned below, It's working
https://www.googleapis.com/youtube/v3/videos?id=Skk6MBoejgU&key={API_KEY}&part=snippet,statistics,contentDetails,player
When I tried to fetch processingDetails,fileDetails,suggestions information, It's throwing error message
https://www.googleapis.com/youtube/v3/videos?id=Skk6MBoejgU&key={API_KEY}&part=processingDetails,fileDetails,suggestions
Error message: forbidden
Can anyone help me to solve this issue ?
Because you need to be connected with your YouTube Channel to get this informations.
In fact, this is private informations, you can only get this informations only from your videos.
We can find this information in the doc of YouTube API V3
forbidden (403) forbidden
The request cannot access user rating information. This error may
occur because the request is not properly authorized to use the
myRating parameter.

How to use YouTube analytics monetary

I am trying to access earnings and monetizedPlaybacks from the YouTube analytics API and all I am able to get is "401 Unauthorized"-Responses. I have logged in using OAuth2 and I used the scopes
https://www.googleapis.com/auth/yt-analytics-monetary.readonly
https://www.googleapis.com/auth/yt-analytics.readonly
https://www.googleapis.com/auth/youtube.readonly
Here is the Java-Snippet that I use in my application:
analytics.reports()
.query("channel==" + channelId, "2013-06-01", "2013-07-01", "earnings,views,monetizedPlaybacks")
.setFilters("video==" + videoId)
.setDimensions("month")
.execute()
I also tried to use the APIs Explorer, but this behaves identical.
If I retrieve only the number of views (no earnings and not monetizedPlaybacks) everything works fine.
I found this bugreport that claims that the API is broken, but it causes remarkably few reactions.
Any ideas appreciated.
This feature is currently not available in the API for youtube partner even though the information can be retrieved using the GUI. Instead a CMS-Account is needed.
There is a bugreport / feature request about the issue:
https://code.google.com/p/gdata-issues/issues/detail?id=4826

Resources