Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread Display Modes
Old Dec 26, 2012, 09:32 PM   #1
macrumors member
Join Date: Jul 2011
verifying YouTube log-in from iphone app

I have an app in which the user uploads a video to youtube. I have the user input their password and username to sign in and then they input the "title", "description", "tags", "category", and "privacy setting" i.e. public, private, unlisted. All works well. However I am not able to verify that the password for the given username is valid or even if the username is valid. When the password and username are filled in and the "sign in" button is tapped these are saved into the documents directory as password.txt and username.txt. Then these are used to complete the process and in fact loaded from the documents directory upon subsequent uploads until the user signs out, in which case the files are removed.
My problem is I would like to check with YouTube when the user fills in the password and username and goes to save them to make sure they are valid. Can someone help me with this.

This is the code I use to input the username and password as well as developers key to YouTube to get a service to allow uploading video.

- (GDataServiceGoogleYouTube *)youTubeService {
    static GDataServiceGoogleYouTube* service = nil;
    if (!service) {
        service = [[GDataServiceGoogleYouTube alloc] init];
        [service setShouldCacheResponseData:YES];
        [service setServiceShouldFollowNextLinks:YES];
        [service setIsServiceRetryEnabled:YES];
        /*[service setUserCredentialsWithUsername:accountView.text password:PasswordDisplayField.text];*/
    NSString *username = [accountView.text retain];
    NSCharacterSet *whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet];
    accountView.text = [username stringByTrimmingCharactersInSet:whitespace];
    /*if ([accountView.text rangeOfString:@"@"].location == NSNotFound)
    { accountView.text = [kYoutubeUsername stringByAppendingString:@"@gmail.com"]; }*/
    if (([accountView.text length] > 0) && ([PasswordDisplayField.text length] > 0))
    { [service setUserCredentialsWithUsername:[accountView.text retain] password:[PasswordDisplayField.text retain]]; }
    { [service setUserCredentialsWithUsername:nil password:nil]; }
    [service setYouTubeDeveloperKey:devKey];
    return service;
and then I use this code to get the URL for uploading

NSURL *url = [GDataServiceGoogleYouTube youTubeUploadURLForUserID:kGDataServiceDefaultUser];

but I am not sure how to use these to check to see if the username and password are matched and compatible and return an error message is they are not . Also I don't want to save them if they are not correct.

If someone can suggest a solution, a tutorial, video or something else to help me accomplish this I would greatly appreciate it.

gbenna is offline   0 Reply With Quote
Old Dec 27, 2012, 08:08 AM   #2
macrumors 603
ArtOfWarfare's Avatar
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
1 - Is saving the password like that really the best idea? It seems like a fairly large security risk... If someone plugs their iOS device into a compromised computer, it could scan all of the iOS device's documents and send them off, could it not? And actually, is iTunes able to read the document from its iOS document sync tab? Your YouTube account is synced with all your other Google Services, including GMail, Google Drive, Google+, which seems like they could contain very important and very private information.

Use Keychain instead to store the username and password: http://stackoverflow.com/questions/6...-within-an-app

2 - I haven't used Google's YouTube APIs, but I'd imagine they include some delegate method indicating whether an upload finished successfully or not.

Edit: It looks like maybe Google doesn't have an iOS YouTube API anymore and now they expect you to use the JavaScript API instead?

This is a bit dated (from 2008) and doesn't show uploading as far as I can tell, but they do include using OAuth 2.0 to login, so you might find this sample code from Google helpful:


Last edited by ArtOfWarfare; Dec 27, 2012 at 08:26 AM.
ArtOfWarfare is offline   0 Reply With Quote
Old Dec 29, 2012, 07:30 PM   #3
Thread Starter
macrumors member
Join Date: Jul 2011
I have changed my code to put the password into the keychain and that works fine. I looked at the site you referenced but when I went to use it they were various errors. I am trying to use Client log in which is depricated for now but will work until 2015. So I would like to use it and get this up and running and then work on updating to Auth3 or whatever they come up with by then. I see there is YouTubeRequestSettings which equates the client id, developer code, username and password. But now I am looking for how to use it. I find this very frustrating as I have everything working. The video, title, description, tags, privacy. Everything works great so long as the correct username and password are typed in. Why is it so difficult to find somewhere where this is documented on how to do. Sorry I'm just frustrated. Thanks
gbenna is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

gdata, log-in, youtube

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
How do you log out of a Youtube account on the YouTube app on iPhone 5? piatti iPhone 4 Dec 12, 2013 12:36 PM
In App Purchase: Is it compulsory to verifying store receipts? cthesky iPhone/iPad Programming 2 Jan 9, 2013 12:09 AM
iPhone 5 users- YouTube app or YouTube safari? The Game 161 iPhone and iPod touch Apps 9 Oct 12, 2012 11:26 PM
Can't log into YouTube app mpossoff iPhone Tips, Help and Troubleshooting 1 Aug 12, 2012 09:13 PM
App Store crashes when I log in or log out echo.park OS X 10.8 Mountain Lion 1 Aug 3, 2012 12:52 PM

Forum Jump

All times are GMT -5. The time now is 10:48 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2015, MacRumors.com, LLC