我的完整错误:
"例外com.google.api.client.googleapis.json.GoogleJsonResponseException:401未经授权"
以下是我的Gradle代码示例:
HttpTransport httpTransport = new NetHttpTransport();
JsonFactory jsonFactory = new JacksonFactory();
GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(jsonFactory)
.setClientSecrets(clientId, clientSecret).build();
credential.setAccessToken(videoDetails.accessToken);
youtube = new YouTube.Builder(httpTransport, jsonFactory, credential).setApplicationName(
"My_Videos").build();
System.out.println(":::uploadind videos on youtube");
Video videoObjectDefiningMetadata = new Video();
setSnippets(videoDetails, videoObjectDefiningMetadata)
InputStreamContent mediaContent = new InputStreamContent(VIDEO_FILE_FORMAT, new BufferedInputStream(new FileInputStream("/home/Desktop/uploadedVideos/146354902123990438f03164744e5a43f635081ba48dc.mp4")));
YouTube.Videos.Insert videoInsert = youtube.videos().insert("snippet,statistics,status", videoObjectDefiningMetadata, mediaContent);
MediaHttpUploader uploader = videoInsert.getMediaHttpUploader();
uploader.setDirectUploadEnabled(false);
Video returnedVideo = videoInsert.execute();
res.put("Id", returnedVideo.getId())
res.put("Tittle",returnedVideo.getSnippet().getTitle())
res.put("isSuccess", true)
println res
此代码工作时间为六个月,但现在它给了我例外。请帮助。