本文整理汇总了Java中com.google.api.services.androidpublisher.AndroidPublisherScopes类的典型用法代码示例。如果您正苦于以下问题:Java AndroidPublisherScopes类的具体用法?Java AndroidPublisherScopes怎么用?Java AndroidPublisherScopes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AndroidPublisherScopes类属于com.google.api.services.androidpublisher包,在下文中一共展示了AndroidPublisherScopes类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: authorizeWithServiceAccount
import com.google.api.services.androidpublisher.AndroidPublisherScopes; //导入依赖的package包/类
private static Credential authorizeWithServiceAccount(String serviceAccountEmail)
throws GeneralSecurityException, IOException {
log.info(String.format("Authorizing using Service Account: %s", serviceAccountEmail));
// Build service account credential.
log.info("Loading service account key ...");
final InputStream is = AndroidPublisherHelper.class.getResourceAsStream(SRC_RESOURCES_KEY_P12);
File keyFile = getTempFile(is, "key");
log.info("keyFile.exists() = " + keyFile.exists());
log.info("keyFile.length() = " + keyFile.length());
GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(HTTP_TRANSPORT)
.setJsonFactory(JSON_FACTORY)
.setServiceAccountId(serviceAccountEmail)
.setServiceAccountScopes(
Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER))
.setServiceAccountPrivateKeyFromP12File(keyFile)
.build();
return credential;
}
示例2: authorizeWithInstalledApplication
import com.google.api.services.androidpublisher.AndroidPublisherScopes; //导入依赖的package包/类
/**
* Authorizes the installed application to access user's protected data.
*
* @throws IOException
* @throws GeneralSecurityException
*/
private static Credential authorizeWithInstalledApplication() throws IOException {
log.info("Authorizing using installed application");
// load client secrets
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(
JSON_FACTORY,
new InputStreamReader(
AndroidPublisherHelper.class
.getResourceAsStream(RESOURCES_CLIENT_SECRETS_JSON)));
// Ensure file has been filled out.
checkClientSecretsFile(clientSecrets);
dataStoreFactory = new FileDataStoreFactory(DATA_STORE_DIR);
// set up authorization code flow
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow
.Builder(HTTP_TRANSPORT,
JSON_FACTORY, clientSecrets,
Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER))
.setDataStoreFactory(dataStoreFactory).build();
// authorize
return new AuthorizationCodeInstalledApp(
flow, new LocalServerReceiver()).authorize(INST_APP_USER_ID);
}
示例3: authorizeWithServiceAccount
import com.google.api.services.androidpublisher.AndroidPublisherScopes; //导入依赖的package包/类
private static Credential authorizeWithServiceAccount(String serviceAccountEmail,
File serviceAccountKeyFile)
throws GeneralSecurityException, IOException {
log.info(String.format("Authorizing using Service Account: %s", serviceAccountEmail));
// Build service account credential.
log.info("Using service key file: "+serviceAccountKeyFile.getAbsolutePath());
GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(HTTP_TRANSPORT)
.setJsonFactory(JSON_FACTORY)
.setServiceAccountId(serviceAccountEmail)
.setServiceAccountScopes(
Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER))
.setServiceAccountPrivateKeyFromP12File(serviceAccountKeyFile)
.build();
return credential;
}
示例4: authorizeWithInstalledApplication
import com.google.api.services.androidpublisher.AndroidPublisherScopes; //导入依赖的package包/类
/**
* Authorizes the installed application to access user's protected data.
*
* @throws IOException
* @throws GeneralSecurityException
*/
private static Credential authorizeWithInstalledApplication() throws IOException {
log.info("Authorizing using installed application");
// load client secrets
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(
JSON_FACTORY,
new InputStreamReader(
AndroidPublisherHelper.class
.getResourceAsStream(RESOURCES_CLIENT_SECRETS_JSON)));
// Ensure file has been filled out.
checkClientSecretsFile(clientSecrets);
dataStoreFactory = new FileDataStoreFactory(DATA_STORE_DIR);
// set up authorization code flow
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow
.Builder(HTTP_TRANSPORT,
JSON_FACTORY, clientSecrets,
Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER))
.setDataStoreFactory(dataStoreFactory).build();
// authorize
return new AuthorizationCodeInstalledApp(
flow, new LocalServerReceiver()).authorize(INST_APP_USER_ID);
}
示例5: authorizeWithServiceAccount
import com.google.api.services.androidpublisher.AndroidPublisherScopes; //导入依赖的package包/类
/**
* Global instance of the {@link com.google.api.client.util.store.DataStoreFactory}. The best practice is to
* make it a single globally shared instance across your application.
*/
private static Credential authorizeWithServiceAccount(String serviceAccountEmail, File pk12File)
throws GeneralSecurityException, IOException {
log.info(String.format("Authorizing using Service Account: %s", serviceAccountEmail));
// Build service account credential.
GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(HTTP_TRANSPORT)
.setJsonFactory(JSON_FACTORY)
.setServiceAccountId(serviceAccountEmail)
.setServiceAccountScopes(
Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER))
.setServiceAccountPrivateKeyFromP12File(pk12File)
.build();
return credential;
}
示例6: init
import com.google.api.services.androidpublisher.AndroidPublisherScopes; //导入依赖的package包/类
public static AndroidPublisher init(Context context, String fileName) throws IOException {
Preconditions.checkArgument(!Strings.isNullOrEmpty(context.getPackageName()), "applicationId cannot be null or empty!");
newTrustedTransport();
GoogleCredential credential = GoogleCredential.fromStream(context.getAssets().open(fileName), HTTP_TRANSPORT, JSON_FACTORY);
credential = credential.createScoped(Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER));
return new AndroidPublisher.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential)
.setApplicationName(context.getPackageName())
.build();
}
示例7: authorizeWithServiceAccount
import com.google.api.services.androidpublisher.AndroidPublisherScopes; //导入依赖的package包/类
private static Credential authorizeWithServiceAccount(String serviceAccountEmail)
throws GeneralSecurityException, IOException {
log.info(String.format("Authorizing using Service Account: %s", serviceAccountEmail));
// Build service account credential.
GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(HTTP_TRANSPORT)
.setJsonFactory(JSON_FACTORY)
.setServiceAccountId(serviceAccountEmail)
.setServiceAccountScopes(
Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER))
.setServiceAccountPrivateKeyFromP12File(new File(PropertiesComponent.getInstance().getValue(GoogleConfigurationView.KEY_PATH_TO_P12)))
.build();
return credential;
}
示例8: authorizeWithServiceAccount
import com.google.api.services.androidpublisher.AndroidPublisherScopes; //导入依赖的package包/类
private static Credential authorizeWithServiceAccount(String serviceAccountEmail)
throws GeneralSecurityException, IOException {
log.info(String.format("Authorizing using Service Account: %s", serviceAccountEmail));
// Build service account credential.
GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(HTTP_TRANSPORT)
.setJsonFactory(JSON_FACTORY)
.setServiceAccountId(serviceAccountEmail)
.setServiceAccountScopes(
Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER))
.setServiceAccountPrivateKeyFromP12File(new File(SRC_RESOURCES_KEY_P12))
.build();
return credential;
}
示例9: getScopes
import com.google.api.services.androidpublisher.AndroidPublisherScopes; //导入依赖的package包/类
@Override
public Collection<String> getScopes() {
return Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER);
}