本文整理汇总了Java中com.google.api.services.youtube.YouTubeScopes类的典型用法代码示例。如果您正苦于以下问题:Java YouTubeScopes类的具体用法?Java YouTubeScopes怎么用?Java YouTubeScopes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
YouTubeScopes类属于com.google.api.services.youtube包,在下文中一共展示了YouTubeScopes类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.google.api.services.youtube.YouTubeScopes; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
if (args.length == 0) {
showUsage();
return;
}
switch (args[0]) {
case "login":
System.out.print("Paste the client ID JSON from the Google API console:");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String clientSecret = br.readLine();
List<String> scopes = new ArrayList<String>();
scopes.add(YouTubeScopes.YOUTUBE_FORCE_SSL);
scopes.add(YouTubeScopes.YOUTUBE);
Auth.authorize(scopes, clientSecret, YouTubeChat.MODID);
break;
case "logout":
Auth.clearCredentials();
break;
default:
showUsage();
}
}
示例2: getCredentials
import com.google.api.services.youtube.YouTubeScopes; //导入依赖的package包/类
public static GoogleAccountCredential getCredentials(Context ctx, boolean useDefaultAccount) {
if (credential == null) {
List<String> scopes = Arrays.asList(YouTubeScopes.YOUTUBE);
credential = GoogleAccountCredential.usingOAuth2(ctx.getApplicationContext(), scopes);
// add account name if we have it
String accountName = null;
if (useDefaultAccount)
accountName = accountName(ctx);
if (accountName != null)
credential.setSelectedAccountName(accountName);
}
return credential;
}
示例3: upload
import com.google.api.services.youtube.YouTubeScopes; //导入依赖的package包/类
@Override
public void upload(Account account, HashMap<String, String> valueMap) {
Timber.d("Upload file: Entering upload");
String title = valueMap.get(VALUE_KEY_TITLE);
String body = valueMap.get(VALUE_KEY_BODY);
String mediaPath = valueMap.get(VALUE_KEY_MEDIA_PATH);
boolean useTor = (valueMap.get(VALUE_KEY_USE_TOR).equals("true")) ? true : false;
List<String> scopes = new ArrayList<String>();
scopes.add(YouTubeScopes.YOUTUBE_UPLOAD);
//set username
GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(super.mContext, scopes);
credential.setSelectedAccountName(account.getCredentials());
//set proxy
useTor=false; //FIXME Hardcoded until we find a Tor workaround
if(super.torCheck(useTor, super.mContext)) {
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(ORBOT_HOST, ORBOT_HTTP_PORT));
transport = new NetHttpTransport.Builder().setProxy(proxy).build();
}
mYoutube = new com.google.api.services.youtube.YouTube.Builder(transport, jsonFactory, credential)
.setApplicationName(mContext.getString(R.string.google_app_name))
.setGoogleClientRequestInitializer(new YouTubeRequestInitializer(CLIENT_ID))
.build();
File mediaFile = new File(mediaPath);
YouTube.Videos.Insert requestInsert = prepareUpload(title, body, mediaFile);
new VideoUploadAsyncTask().execute(requestInsert);
}