Getting developer key error when uploading videos through YouTube API

I’m having trouble uploading videos to YouTube using their API and keep running into authentication issues. The error message says I need a developer key but I’m not sure what I’m doing wrong.

public class VideoUploader {
    private static final String DEV_KEY = "my-developer-key-here";
    private static final String USERNAME = "my_username";
    private static final String PASSWORD = "my_password";
    
    public void uploadToYouTube() throws Exception {
        YouTubeService ytService = new YouTubeService("MyApp", DEV_KEY);
        
        try {
            ytService.setUserCredentials(USERNAME, PASSWORD);
        } catch (AuthenticationException ex) {
            System.out.println("Login failed");
            return;
        }
        
        VideoEntry video = new VideoEntry();
        YouTubeMediaGroup mediaGroup = video.getOrCreateMediaGroup();
        
        mediaGroup.setTitle(new MediaTitle());
        mediaGroup.getTitle().setPlainTextContent("Sample Video Title");
        mediaGroup.addCategory(new MediaCategory(YouTubeNamespace.CATEGORY_SCHEME, "Entertainment"));
        mediaGroup.setDescription(new MediaDescription());
        mediaGroup.getDescription().setPlainTextContent("Video description here");
        
        MediaFileSource fileSource = new MediaFileSource(new File("myvideo.mp4"), "video/mp4");
        video.setMediaSource(fileSource);
        
        String uploadEndpoint = "https://uploads.gdata.youtube.com/feeds/api/users/default/uploads";
        VideoEntry uploadedVideo = ytService.insert(new URL(uploadEndpoint), video);
        
        System.out.println("Video uploaded successfully");
    }
}

The error I get is:

com.google.gdata.util.ServiceForbiddenException: Developer key required for this operation

I have a valid API key but it seems like it’s not being recognized properly. Do I need to register my application somewhere or enable specific permissions? Any guidance would be helpful since the Google documentation wasn’t clear about this part.

Yeah, it’s definitely the deprecated GData library like everyone’s saying. I migrated from this about two years ago - the auth flow is completely different now. You’ve got to ditch setUserCredentials entirely and switch to OAuth 2.0 consent flow. Set up a new project in Google Cloud Console, enable YouTube Data API v3, and grab your OAuth 2.0 client credentials. Now users have to authorize your app through a browser redirect, which gives you tokens for API calls. Swap out VideoEntry for YouTube.Videos.Insert from the v3 client library. Way more complex than before, but much more secure than the old username/password setup.

That error means you’re using an outdated auth method. YouTube’s API v2 with username/password was killed off years ago - it just doesn’t work anymore. You’ve got to switch to API v3 with OAuth 2.0 instead of that old developer key setup. The GData library you’re using is legacy and won’t function now. Grab the current YouTube Data API v3 Java client and set up OAuth 2.0. You’ll need to create credentials in Google Cloud Console, download the config file, and handle OAuth properly. Had the exact same problem when I updated an old project last year - this fixed it.

yeah, Finn’s totally right - it’s an api version issue. google dished gdata a while back. you gotta switch to oauth2 with v3 api, which is super diff. head to google cloud console, make a project, enable youtube data api, and get your client creds json. then forget that old videoentry stuff and use the new youtube client lib instead.