当前位置: 首页>>代码示例>>Java>>正文


Java YouTubeScopes类代码示例

本文整理汇总了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();
  }
}
 
开发者ID:youtube,项目名称:youtube-chat-for-minecraft,代码行数:24,代码来源:Main.java

示例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;
}
 
开发者ID:sgehrman,项目名称:UTubeTV,代码行数:19,代码来源:Auth.java

示例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);
}
 
开发者ID:StoryMaker,项目名称:SecureShareLib,代码行数:33,代码来源:YoutubeSiteController.java


注:本文中的com.google.api.services.youtube.YouTubeScopes类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。