Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3755

Youtube Data V3 Insert video Unauthorized

$
0
0

I'm a junior developer that wants to get started with Google Cloud.

I just created a project on GCP.

  • I enabled Youtube data v3 api.
  • Created a key for my service account
  • Created a Youtube channel

I integrated the Service account JSON with my project based on the guide at https://developers.google.com/zero-touch/guides/customer/quickstart/java-service-account

I tried to insert a video from my local file system to Youtube and I get exceeded quota error and I wasn't able to successfully upload a simple video of less than 2mb before this happened because I kept trying.

Attached are screenshots and code snippets

enter image description here

enter image description here

My code snippets

      String localFilePath = "/home/ubuntu/video.mp4";      FileContent videoContent = new FileContent("video/*", new File(localFilePath));      final NetHttpTransport HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();      YouTube youTube = new YouTube.Builder(HTTP_TRANSPORT, JSON_FACTORY, new HttpCredentialsAdapter(getServiceCredential()))        .setApplicationName("Game")        .build();      YouTube.Videos.Insert videoInsert = youTube.videos()        .insert(Collections.singletonList("snippet,statistics,status"), videoMetadata, videoContent);  private InputStream getCredentialInputStream() throws IOException {    InputStream in = YouTubeService.class.getResourceAsStream(CREDENTIAL_PATH);    if (in == null) {      throw new FileNotFoundException("Resource not found: ".concat(CREDENTIAL_PATH));    }    return in;  }  private GoogleCredentials getServiceCredential() throws IOException {    GoogleCredentials credentials = ServiceAccountCredentials.fromStream(        Objects.requireNonNull(getCredentialInputStream()))      .createScoped(SCOPES);    return credentials;  }

Viewing all articles
Browse latest Browse all 3755

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>