Im triển khai ứng dụng Android cho phép người dùng truyền trực tiếp sang kênh youtube từ ứng dụng. Tôi đã tạo khóa API và ID khách hàng OAuth 2.0 com.google.android.gms.auth.GoogleAuthException: UNREGISTERED_ON_API_CONSOLE
Nhưng tôi nhận được một ngoại lệ sau đây: com.google.android.gms.auth.GoogleAuthException: UNREGISTERED_ON_API_CONSOLE
hoặc khi tôi cố gắng tổ chức sự kiện hoặc khi tôi cố gắng tìm kiếm sự kiện được tạo theo cách thủ công trên kênh youtube.
tôi sử dụng đoạn mã sau để tạo ra một đối tượng youtube
String accountName = mContext.getString(R.string.google_account_name);
String apiKey = mContext.getString(R.string.google_api_key);
String clientID = mContext.getString(R.string.google_api_client_id);
String clientName = mContext.getString(R.string.google_api_client_name);
GoogleAccountCredential credential =
GoogleAccountCredential.usingOAuth2(mContext,
Arrays.asList(YouTubeScopes.YOUTUBE));
credential.setSelectedAccountName(accountName);
// String SCOPE = "audience:server:client_id:" + clientID + ":api_scope:" + YouTubeScopes.YOUTUBE;
// GoogleAccountCredential credential = GoogleAccountCredential.usingAudience(mContext, SCOPE);
// credential.setSelectedAccountName(accountName);
youtube = new YouTube.Builder(transport, jsonFactory, credential)
.setApplicationName(clientName)
.setYouTubeRequestInitializer(new YouTubeRequestInitializer(apiKey))
/*.setGoogleClientRequestInitializer(new YouTubeRequestInitializer(apiKey))*/
.build();
Sau đó, để tạo ra một sự kiện:
LiveBroadcastSnippet broadcastSnippet = new LiveBroadcastSnippet();
broadcastSnippet.setTitle(name);
broadcastSnippet.setScheduledStartTime(new DateTime(futureDate));
LiveBroadcastContentDetails contentDetails = new LiveBroadcastContentDetails();
MonitorStreamInfo monitorStream = new MonitorStreamInfo();
monitorStream.setEnableMonitorStream(false);
contentDetails.setMonitorStream(monitorStream);
// Create LiveBroadcastStatus with privacy status.
LiveBroadcastStatus status = new LiveBroadcastStatus();
status.setPrivacyStatus("unlisted");
LiveBroadcast broadcast = new LiveBroadcast();
broadcast.setKind("youtube#liveBroadcast");
broadcast.setSnippet(broadcastSnippet);
broadcast.setStatus(status);
broadcast.setContentDetails(contentDetails);
// Create the insert request
YouTube.LiveBroadcasts.Insert liveBroadcastInsert = youtube
.liveBroadcasts().insert("snippet,status,contentDetails",
broadcast);
// Request is executed and inserted broadcast is returned
LiveBroadcast returnedBroadcast = liveBroadcastInsert.execute(); //<= This line generates the exception
tôi rõ ràng đã làm điều gì sai, nhưng tôi không thể tìm ra những gì. Bất kỳ trợ giúp được đánh giá cao. Cảm ơn trước
Khởi động lại IDE không tạo lại tệp. Tôi có cần phải làm gì nữa không? –
Điều tương tự cũng xảy ra với tôi. –
Thử các đề xuất trong https://stackoverflow.com/questions/3997748/how-can-i-create-a-keystore –