Upload video to youtube with hardcode username & password ios

910 views Asked by At

I am developing an iPhone application. This app supports a feature where the user can upload a video to a common static Youtube account which is shared by all the app users. When the app receives an upload request, it internally logs-in to the common Youtube account and uploads the video.

As per my understanding OAuth is the secure way to login to any site compared to non-Oauth. Since only the app knows the user-name and password, a login dialog (UIWebView with user-name and password fields) should not be prompted to the user.

Is there any mechanism available in GData framework that supports OAuth authentication without prompting the user for user-name and password ( i.e OAuth authentication with hard-coded user name and password.

Any solution please suggest.

2

There are 2 answers

0
Linda Lawton - DaImTo On

Client login which was discontinued / shutdown began on April 20 2015 and probably completed around May 26 2015. You can no longer use client login (Login and password) with the YouTube API, you need to switch to Oauth2.

No there is no other way of uploading to the YouTube API. You must us oauth2.

Normally I would say use a service account to upload to this static account but it is not possible to use a service account with the YouTube API.

0
AudioBubble On

I was working on this a while back, so below are some things you need to think about in order to do this. Before I start, I answered a very similar question to this on SO, it may be worth a read: https://stackoverflow.com/a/29986142/4657588

Step 1

So in order to upload YouTube videos, you do need to use OAuth to securely login. Specifically OAuth 2.0 as this is what the YouTube API 3.0 needs. There are plenty of good OAuth 2.0 libraries out there which will allow you to connect/authorise with the YouTube V3 API. Have a look on sites like CocoaControls and Github.

Step 2

Once your app is logged into the YouTube V3 API and has been granted access, you can then upload your video.

There are 2 POST requests you need to make to the YouTube V3 API. The first will make the YouTube V3 API return a upload URL (in JSON format).

As for the second request, you then use the URL that the YouTube V3 API returned to you to upload the actual video file. Add the video file as part of the POST request BODY.

I hope this helps :)