setapikey issue persists
This commit is contained in:
@@ -1,8 +1,14 @@
|
|||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
|
||||||
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
|
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
|
||||||
|
import com.google.api.client.googleapis.services.AbstractGoogleClientRequest;
|
||||||
|
import com.google.api.client.googleapis.services.GoogleClientRequestInitializer;
|
||||||
|
import com.google.api.client.http.javanet.NetHttpTransport;
|
||||||
import com.google.api.client.json.JsonFactory;
|
import com.google.api.client.json.JsonFactory;
|
||||||
|
import com.google.api.client.json.jackson2.JacksonFactory;
|
||||||
import com.google.api.services.youtube.YouTube;
|
import com.google.api.services.youtube.YouTube;
|
||||||
|
|
||||||
public class YouTubeBot {
|
public class YouTubeBot {
|
||||||
@@ -13,12 +19,17 @@ public class YouTubeBot {
|
|||||||
try {
|
try {
|
||||||
this.server = Bukkit.getServer();
|
this.server = Bukkit.getServer();
|
||||||
this.youtube = new YouTube.Builder(
|
this.youtube = new YouTube.Builder(
|
||||||
GoogleNetHttpTransport.newTrustedTransport())
|
new NetHttpTransport(),
|
||||||
|
JacksonFactory.getDefaultInstance(),
|
||||||
|
null)
|
||||||
.setApplicationName("Crafty MC")
|
.setApplicationName("Crafty MC")
|
||||||
|
.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
|
||||||
|
@Override
|
||||||
|
public void initialize(AbstractGoogleClientRequest<?> request) throws IOException {
|
||||||
|
request.setKey(apiKey);
|
||||||
|
}
|
||||||
|
})
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// API Key
|
|
||||||
youtube.setApiKey(apiKey);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user