401 unauthorized when trying to insert (create) new table - google-fusion-tables

I am trying to use google-api-services-fusiontables-v1-rev1-1.7.2-beta apis to create new table from my Android application.
I am using the Account manager as described in the Tasks sample and successfully can get token using the scope (AUTH_TOKEN_TYPE) as "fusiontables".
However, when trying to use the service to insert a new table I am getting 401 unauthorized error.
//Create Columns
List <Column> coulmns = createColumn(3,basicCoulmn);
//Create the table
Table table = createTable("TestTable","fusiontables#table","Description", coulmns);
//Call the service
service.table().insert(table).execute();
Here is the error:
com.google.api.client.googleapis.json.GoogleJsonResponseException: 401 Unauthorized
{
"code": 401,
"errors": [
{
"domain": "global",
"location": "Authorization",
"locationType": "header",
"message": "Invalid Credentials",
"reason": "authError"
}
],
"message": "Invalid Credentials"
}
Can you please suggest what I am doing wrong?

Instead of using fusiontables for AUTH_TOKEN_TYPE, what happens if you use oauth2:https://www.googleapis.com/auth/fusiontables?

Related

Unable to fetch data from YT monetisation metrics api endpoint

When we are are trying to fetch data from youtube monetisation metrics api endpoint for an account, but it is providing us with a** forbidden error**. We have also checked for monetaryanalytics scope for that account and it is available in account-props.
We have been receiving a forbidden error without any other error message to act further upon it
Adding the API response here:
{
"error": {
"code": 403,
"message": "Forbidden",
"errors": [
{
"message": "Forbidden",
"domain": "global",
"reason": "forbidden"
}
]
}
}
Can anyone please help on this, any help will be appreciated

Comments: update gives 403 forbidden insufficient permissions

I tried this API here and in my code and got this error everywhere. However, other methods, such as commentThreads.insert() or comments.delete(), work fine, so I don't think this issue is scopes or OAuth 2.0 authorization related.
Here is the response I get:
{
"error": {
"code": 403,
"message": "The comment could not be updated due to insufficient permissions. The request might not be properly authorized.",
"errors": [
{
"message": "The comment could not be updated due to insufficient permissions. The request might not be properly authorized.",
"domain": "youtube.comment",
"reason": "forbidden",
"location": "body",
"locationType": "other"
}
]
}
}
UPD:
Apparently, you can only update the comment under your own video. But you can delete your comment from any video. I don’t know why they did it that way and didn't even write about it in the docs. I also wrote to them on https://issuetracker.google.com/

YouTube API V3 Comment Threads doesn't work with access Token

I am trying to call the following url with my access token which is for getting comments from a video but it doesn't seem to work and gives me a Insufficient Permissions Error.
Here's the URL I try to call-
https://www.googleapis.com/youtube/v3/commentThreads?part=snippet&maxResults=1&videoId=tdUX3ypDVwI&access_token={myAccessToken}
but it sends me the following error:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "insufficientPermissions",
"message": "Insufficient Permission"
}
],
"code": 403,
"message": "Insufficient Permission"
}
}
Apparently, It doesn't make sense to me? Please help.
You need the following scope :
https://www.googleapis.com/auth/youtube.force-ssl

Cannot delete comment on Youtube video via API

I'm trying to delete followiing comment z12mdhjgxrfgtpf3d231jrz5vo3jdj0lo on this video but the response code is 400. I'm using token of the channel's admin with https://www.googleapis.com/auth/youtube.force-ssl scope as it required by documentation.
The request is:
DELETE https://www.googleapis.com/youtube/v3/comments?id=z12mdhjgxrfgtpf3d231jrz5vo3jdj0lo&alt=json
{
"query_params": {
"id": "z12mdhjgxrfgtpf3d231jrz5vo3jdj0lo",
"alt": "json"
}
}
The response:
{
"error": {
"errors": [
{
"domain": "youtube.comment",
"reason": "processingFailure",
"message": "The API server failed to successfully process the request. While this can be a transient error, it usually indicates that the requests input is invalid.",
"locationType": "parameter",
"location": "id"
}
],
"code": 400,
"message": "The API server failed to successfully process the request. While this can be a transient error, it usually indicates that the requests input is invalid."
}
}
What is wrong with the request?
That's token debug info:
{
issued_to: "493985796851.apps.googleusercontent.com",
audience: "493985796851.apps.googleusercontent.com",
user_id: "109704411339866376304",
scope: "https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/youtube.force-ssl https://www.googleapis.com/auth/youtube.upload",
expires_in: 2452,
access_type: "offline"
}
The reason you're not able to delete the comment is that you're using Comments.delete to remove comment which was written by other users . Comments.delete only deletes your own comments in your video.
To delete comment of other users, use Comments.setModerationStatus and set moderationStatus to "rejected".
So just repeat what you did but this time using Comments.setModerationStatus. There's a Try-it in the link for testing purposes.

I have Google OAuth 2.0 Authorzation Token. When using file_get_contents its saying i'm still not authorized?

I've been trying to write a little script with Google's API. I've managed to set it up to get the actual access token and echo it in the browser but when i try to:
$views = file_get_contents('https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3DMINE&start-date=2014-09-29&end-date=2014-10-29&metrics=views&key={key}');
var_dump($views);
It's still giving me the default error of
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
If any more information is needed like my request, please let me know. I feel that maybe i'll be missing something simple like usual :l !!!
Thanks in advance!
The Parameter for the access token is access_token, not key.
Your URL has to be
https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3DMINE&start-date=2014-09-29&end-date=2014-10-29&metrics=views&access_token={access_token}

Resources