1

I want to get the users youtube usedID. After successfully login with youTubeService. On the viewController:finishedWithAuth:error: userID returns nil.

Code

- (void)viewController:(GTMOAuth2ViewControllerTouch *)viewController
          finishedWithAuth:(GTMOAuth2Authentication *)auth
                     error:(NSError *)error
    {
        [viewController dismissViewControllerAnimated:YES completion:NULL];
        if(error != nil){
            NSLog(@"Authentication error: %@", error);
        }
        else {
            // Authentication succeeded...
            NSLog(@"%@",auth.accessToken);
            NSLog(@"%@",auth.userID); //returns nil
        }
    }

Please note that I am not asking Google email ID I want to get youtube user id.

Filburt
  • 17,626
  • 12
  • 64
  • 115
Sunny Shah
  • 12,990
  • 9
  • 50
  • 86
  • possible duplicate of [How to get user id after login with google oauth](http://stackoverflow.com/questions/12662127/how-to-get-user-id-after-login-with-google-oauth) – Tim Cavanaugh Nov 19 '13 at 19:36
  • i have seen this answer and i have also tried the userinfo URL to get the userid but actually it returns the google user id that i dont want. { "email": "XXX@gmail.com", "verified_email": true } – Sunny Shah Nov 19 '13 at 19:48
  • Did you look at this answer in the suggested duplicate? http://stackoverflow.com/a/12696891/449161 – Ben Flynn Nov 19 '13 at 23:39

1 Answers1

1

I believe you are asking about "legacy" usernames. You can't get it from channel.

But if you know a username, you can find the channel with channels.list(part="id", forUsername="username")

On other hand, usernames are not unique, and not useful on the API. What you need instead is the channel ID.

This guide describes it.

If you are looking a title to show, then you can use channel's title.

Ibrahim Ulukaya
  • 12,767
  • 1
  • 33
  • 36