YouTube API v3 sample project raising GTLJSONRPCErrorDomain -32602 bad request error - objective-c

I have just downloaded the Google API objective C client. I opened the YouTube example project in Xcode on my Mac. It builds and runs without errors.
I registered a project with Google APIs, and created a Client ID for installed applications, choosing iOS and entering the sample code's Bundle ID, com.example.YouTubeSample. I left the App Store ID blank and deep linking disabled.
I entered the resulting Client ID and Client secrets into the sample app. I signed myself into Google through the app's window too, and it tells me I am signed in.
Independently I went to YouTube and uploaded a 1Mb .mov file, which uploads fine (although it tells me there may be an audio/video sync issue).
I then uploaded the same file through the sample app. When it finished, it gave me the error:
Error Domain=com.google.GTLJSONRPCErrorDomain Code=-32602
"The operation couldn’t be completed. (Bad Request)"
UserInfo=0x.... {error=Bad Request, NSLocalizedFailureReason=(Bad Request),
GTLStructuredError=GTLErrorObject 0x...:
{message:"Bad Request" data:[1] code:-32602}}
(Since the sample app is for Mac OS, not iOS, I also tried creating a second Client ID in Google APIs, for an installed application of type "other". I entered this new ID and secret into the sample app, and when I uploaded the .mov file I got the same error.)
Over in the API console, I see an error report showing some new Error code 400s.
What have I done wrong?
thanks!

The YouTube API packs a "structured error" object inside of the NSError object that it returns. The structured error is a GTLErrorObject that can be inspected to find the reason for the error:
uploadTicket = [service executeQuery:query
completionHandler:^(GTLServiceTicket* ticket, id object, NSError* error) {
if (error) {
GTLErrorObject* const errorObject = error.userInfo[kGTLStructuredErrorKey];
NSLog(#"error from YouTube API: %#", errorObject.data);
}
...
}];
Sample output (formatted for clarity):
error from YouTube API: (
GTLErrorObjectData 0x7fb0c4cc9f10: {
message:"Bad Request"
locationType?:"other"
reason:"invalidCategoryId"
domain:"youtube.video"
location:"body.snippet.categoryId"}
)

I just quit and restarted Xcode and the sample project, and it worked (using the iOS client ID, I haven't tried the other one).
Happy days!

Related

Anyone know how to fix the new OAuth2 error when trying to authenticate a PyDrive application?

I don't think this issue is specific to PyDrive, but rather Google OAuth. However, some of the solutions I've seen on stackoverflow don't seem to be transferable over to my PyDrive application, which is just a python script to upload files programmatically to a shared drive. It worked fine 2 months ago but I tried to rerun it today and it's not working. Here is the error I'm getting:
Authorisation Error
Error 400: invalid_request
You can't sign in to this app because it doesn't comply with Google's OAuth 2.0 policy for keeping apps secure.
You can let the app developer know that this app doesn't comply with one or more Google validation rules.
Request Details
The content in this section has been provided by the app developer. This content has not been reviewed or verified by Google.
If you’re the app developer, make sure that these request details comply with Google policies.
redirect_uri: urn:ietf:wg:oauth:2.0:oob
I am using a web application OAuth 2.0 Client ID creds on GCP. All secrets are stored in a local client_secrets.json file.
I run my script, it sends a message to the console that says
Go to the following link in your browser:
https://accounts.google.com/o/oauth2/auth?client_id=blahblahblah.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&access_type=offline&response_type=code
Enter verification code:
How it used to work: After I click the link above, it returns a code I paste into the console and then its authenticated. FYI: I plan on running this 24/7 on a remote server.
Now: I click the link above and get the error I posted above. I've tried to change the redirect uri to 127.0.0.1 and it does allow me to auth, then I get a code in my URL, but once I copy that and paste it into the console, I get more errors.
Anyone know the solution for this?

Trying to get Vimeo API to recognize the upload file

I am using Expo managed Workflow with react-native and trying desperately to not have to eject. The only sticking point in the entire app is allowing users of the app to upload video into a usable format. I am hoping to use Vimeo as the video hosting service.
I am authenticated and verified and interacting with the Vimeo API.
On my express server when I run this code:
let Vimeo = require('vimeo').Vimeo;
let client = new Vimeo({vimeo creds});
client.request({
method: 'GET',
path: '/tutorial'
}, function (error, body, status_code, headers) {
if (error) {
console.log(error);
}
console.log(body);
})
I see this message:
message: 'Success! You just interacted with the Vimeo API. Your dev environment is configured correctly, and the client ID, client secret, and access token that you provided are all working fine.',
next_steps_link: 'https://developer.vimeo.com/api/guides/videos/upload',
token_is_authenticated: true
I successfully uploaded a video from my express server using this code and placing the file on the same directory as the server code.
client.upload(
"{filename}",
{
'name': ' Test Video 1',
'description': 'The description goes here.'
},
function (uri) {
console.log('Your video URI is: ' + uri);
},
function (bytes_uploaded, bytes_total) {
var percentage = (bytes_uploaded / bytes_total * 100).toFixed(2)
console.log(bytes_uploaded, bytes_total, percentage + '%')
},
function (error) {
console.log('Failed because: ' + error)
}
)
Then, I added the same functionality to my web app locally for testing but not on an express server, trying to do it within a react native app running in a browser (for starters). I still get the message that says I am successfully interacting with Vimeo API and that I am authenticated.
However, When I try to add the file in the react native app with the exact same code, except this is how I am accessing the video file from react native: filename = require({pathToFile});
and the failed response says:
"Failed because: Unable to locate file to upload."
I do not know if the message is incorrect and if Vimeo API is having issues understanding the file or if it could be that because I am no longer running on a server.
So I keep trying to make sense of how to do this but wonder if I am missing something at this stage of testing.
Because...
I am able to upload the video to Firebase Storage by using expo-image-picker.
When I try to give the Vimeo API the file from what I have retrieved from the filesystem, it still says it is unable to locate file to upload.
In this case the string I am trying to upload looks like this: data:video/quicktime;base64,AAAAHGZ0eXBtcDQyAAAAAW…5AQLMKwEjd8ABNvCVAUgYoQFR1yYBVZYxAVX9NwFXEy8BYh0m
Any suggestions of a way to get Vimeo api to recognize this file?
I really want to use Vimeo for this project I can't find anything on stack overflow related to this except this one question which noone has attempted to answer:
Failed because: Unable to locate file to upload but path is correct (Vimeo API)

Safari Push notification is not working

I have been trying Safari push notification. I followed the Apple doc.
Downloaded Apple intermediate Certificate AppleWWDRCA.cer. Exported my website provisioning profile as p12. To create the push Package used ruby package push_package
It created a package zip and it contains all the details that we needed - icon.iconset, manifest.json, signature and website.json.
When I request permission it successfully retrieves all data and gives me token.
But the real problem is when I try to send notification from a PHP script or APN tester its not receiving in the safari. The v1/logs getting called instead with some circular Json object.
Have no idea what to do next. can anyone please help ??
And one more thing I found is, in the logs SafariNotificationAgent (unknown version)
The error was in payload that I used.
It should be like:
{
"aps":{
"alert":{
"title":"Hi there",
"body":"How are you",
"action":"viewed"
},
"url-args":[""]
}
}

PushWoosh Error : status code : 210 status_message: Invalid device token for Android

I am trying to register device token on pushwoosh services using API but it's returning me following response (Form Pushwoosh service) :
{ status_code: 210,
status_message: 'Invalid token: apa91bhosngjexchs528yuy-y4woqtkoo5b3ydddkh29etjm6eg9thg5urchcqaae32lavevq5vdco6mbyozyld4mqajg_t8-aaqnxiz6fr1gwnml7maurolpibo7-hj3at5l3i7zvzw',
response: null }
I am using Same API for iOS and it's working fine for iOS.
But the problem is with Android device. Also device token is correct (Started from "AP91...") and App is registered onGCM as well.
Thanks for help.
I got the solution and it's silly mistake I have done.
Just Uploading Answer if someone new learner get stuck, so it will helpful.
While making API call to pushwoosh registration we are sending following request in API.
"request":{
"application":"84170-XXXXX",
"push_token":deviceInfo.deviceToken,
"language":"en",
"hwid": deviceInfo.HardwareID,
"timezone": 3600,
"device_type":deviceType
}
Mistake was I missed hwid which is unique (We are using device Mac address now).
Also for Android "device_type" =3 and for ios "device_type"=1 But I earlier I was sending 1 for both (And thats the issue).
Now I am sending it according to device type. (As per given in pushwoosh docs).
and it's working fine now.
Thanks.

OneDrive API: Getting Internal server Error while using action.createLink for a shared file

I am trying to create a publicly shared link for OneDrive files.
I have got onedrive.readwrite scope from the onedrive account(A).
I tried creating a sharing link for the Account A's file using the following call,
https://api.onedrive.com/v1.0/drive/items/{normal_file_id}/action.createLink
and it worked. I got the web url and the status is 200.
Then I shared another Account B's folder with Account A.
Now,
I tried the same by creating a sharing link for the Account A's shared file of Account B using the following call,
https://api.onedrive.com/v1.0/drive/items/{shared_file_id}/action.createLink
Now, I am getting internal server error with status 500.
I tried both these scenarios in Apigee console. getting the same trouble.
Interestingly when I look into the sharing info for the file in Onedrive. I can see a Sharing link created for that file in the name of Apigee Api console.
But, I am always getting 500 errors while working in API. How to rectify this problem?
It looks like this is a bug in the API. The error is happening after link creation but before the API call returns which is why the link is successfully created. Please use the issue you opened on GitHub to track: https://github.com/OneDrive/onedrive-api-docs/issues/237