本文整理汇总了Java中com.google.api.client.util.store.MemoryDataStoreFactory类的典型用法代码示例。如果您正苦于以下问题:Java MemoryDataStoreFactory类的具体用法?Java MemoryDataStoreFactory怎么用?Java MemoryDataStoreFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MemoryDataStoreFactory类属于com.google.api.client.util.store包,在下文中一共展示了MemoryDataStoreFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCredential
import com.google.api.client.util.store.MemoryDataStoreFactory; //导入依赖的package包/类
public final Credential getCredential() {
if (googleCredential == null) {
try {
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
secureHttpTransport,
JacksonFactory.getDefaultInstance(),
googleSecrets,
requiredScopes)
.setAccessType("offline")
.setDataStoreFactory(new MemoryDataStoreFactory())
.build();
googleCredential = new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver())
.authorize("user");
} catch (IOException e) {
//Will not occur
logger.fatal(e);
throw new RuntimeException();
}
}
return googleCredential;
}
示例2: CRESTAuthenticator
import com.google.api.client.util.store.MemoryDataStoreFactory; //导入依赖的package包/类
public CRESTAuthenticator(String userID) {
this.userID = userID;
try {
this.flow = new AuthorizationCodeFlow.Builder(
BearerToken.authorizationHeaderAccessMethod(),
HTTP,
JSON,
new GenericUrl(LOGIN_URL + "/oauth/token"),
new ClientParametersAuthentication(CLIENT_ID, CLIENT_SECRET),
CLIENT_ID,
LOGIN_URL + "/oauth/authorize").
setDataStoreFactory(MemoryDataStoreFactory.getDefaultInstance()).
setScopes(Arrays.asList(SCOPES)).
build();
} catch (Exception e) {
System.out.println(e);
}
}
示例3: RedHatOAuthAuthenticator
import com.google.api.client.util.store.MemoryDataStoreFactory; //导入依赖的package包/类
@Inject
public RedHatOAuthAuthenticator(
@Nullable @Named("oauth.redhat.clientid") String clientId,
@Nullable @Named("oauth.redhat.clientsecret") String clientSecret,
@Nullable @Named("oauth.redhat.redirecturis") String[] redirectUris,
@Nullable @Named("oauth.redhat.authuri") String authUri,
@Nullable @Named("oauth.redhat.tokenuri") String tokenUri,
@Nullable @Named("oauth.redhat.useruri") String userUri)
throws IOException {
if (!isNullOrEmpty(clientId)
&& !isNullOrEmpty(clientSecret)
&& !isNullOrEmpty(authUri)
&& !isNullOrEmpty(tokenUri)
&& !isNullOrEmpty(userUri)
&& redirectUris != null
&& redirectUris.length != 0) {
configure(
clientId, clientSecret, redirectUris, authUri, tokenUri, new MemoryDataStoreFactory());
}
this.userUri = userUri;
}
示例4: LinkedInOAuthAuthenticator
import com.google.api.client.util.store.MemoryDataStoreFactory; //导入依赖的package包/类
@Inject
public LinkedInOAuthAuthenticator(
@Nullable @Named("oauth.linkedin.clientid") String clientId,
@Nullable @Named("oauth.linkedin.clientsecret") String clientSecret,
@Nullable @Named("oauth.linkedin.redirecturis") String[] redirectUris,
@Nullable @Named("oauth.linkedin.authuri") String authUri,
@Nullable @Named("oauth.linkedin.tokenuri") String tokenUri,
@Nullable @Named("oauth.linkedin.useruri") String userUri)
throws IOException {
if (!isNullOrEmpty(clientId)
&& !isNullOrEmpty(clientSecret)
&& !isNullOrEmpty(authUri)
&& !isNullOrEmpty(tokenUri)
&& !isNullOrEmpty(userUri)
&& redirectUris != null
&& redirectUris.length != 0) {
configure(
clientId, clientSecret, redirectUris, authUri, tokenUri, new MemoryDataStoreFactory());
}
this.userUri = userUri;
}
示例5: BitbucketOAuthAuthenticator
import com.google.api.client.util.store.MemoryDataStoreFactory; //导入依赖的package包/类
@Inject
public BitbucketOAuthAuthenticator(
@Nullable @Named("oauth.bitbucket.clientid") String clientId,
@Nullable @Named("oauth.bitbucket.clientsecret") String clientSecret,
@Nullable @Named("oauth.bitbucket.redirecturis") String[] redirectUris,
@Nullable @Named("oauth.bitbucket.useruri") String userUri,
@Nullable @Named("oauth.bitbucket.authuri") String authUri,
@Nullable @Named("oauth.bitbucket.tokenuri") String tokenUri)
throws IOException {
super();
if (!isNullOrEmpty(clientId)
&& !isNullOrEmpty(clientSecret)
&& !isNullOrEmpty(authUri)
&& !isNullOrEmpty(tokenUri)
&& redirectUris != null
&& redirectUris.length != 0) {
configure(
clientId, clientSecret, redirectUris, authUri, tokenUri, new MemoryDataStoreFactory());
}
this.userUri = userUri;
}
示例6: ProjectLockerOAuthAuthenticator
import com.google.api.client.util.store.MemoryDataStoreFactory; //导入依赖的package包/类
@Inject
public ProjectLockerOAuthAuthenticator(
@Nullable @Named("oauth.projectlocker.clientid") String clientId,
@Nullable @Named("oauth.projectlocker.clientsecret") String clientSecret,
@Nullable @Named("oauth.projectlocker.redirecturis") String[] redirectUris,
@Nullable @Named("oauth.projectlocker.authuri") String authUri,
@Nullable @Named("oauth.projectlocker.tokenuri") String tokenUri)
throws IOException {
if (!isNullOrEmpty(clientId)
&& !isNullOrEmpty(clientSecret)
&& !isNullOrEmpty(authUri)
&& !isNullOrEmpty(tokenUri)
&& redirectUris != null
&& redirectUris.length != 0) {
configure(
clientId, clientSecret, redirectUris, authUri, tokenUri, new MemoryDataStoreFactory());
}
}
示例7: OpenShiftGitHubOAuthAuthenticator
import com.google.api.client.util.store.MemoryDataStoreFactory; //导入依赖的package包/类
@Inject
public OpenShiftGitHubOAuthAuthenticator(
@Nullable @Named("che.oauth.github.redirecturis") String[] redirectUris,
@Nullable @Named("che.oauth.github.authuri") String authUri,
@Nullable @Named("che.oauth.github.tokenuri") String tokenUri)
throws IOException {
super("NULL", "NULL", redirectUris, authUri, tokenUri);
if (!isNullOrEmpty(authUri)
&& !isNullOrEmpty(tokenUri)
&& redirectUris != null
&& redirectUris.length != 0) {
configure("NULL", "NULL", redirectUris, authUri, tokenUri, new MemoryDataStoreFactory());
}
}
示例8: configure
import com.google.api.client.util.store.MemoryDataStoreFactory; //导入依赖的package包/类
/**
* @see {@link #configure(String, String, String[], String, String, MemoryDataStoreFactory, List)}
*/
protected void configure(
String clientId,
String clientSecret,
String[] redirectUris,
String authUri,
String tokenUri,
MemoryDataStoreFactory dataStoreFactory)
throws IOException {
configure(
clientId,
clientSecret,
redirectUris,
authUri,
tokenUri,
dataStoreFactory,
Collections.emptyList());
}
示例9: GitHubOAuthAuthenticator
import com.google.api.client.util.store.MemoryDataStoreFactory; //导入依赖的package包/类
@Inject
public GitHubOAuthAuthenticator(
@Nullable @Named("che.oauth.github.clientid") String clientId,
@Nullable @Named("che.oauth.github.clientsecret") String clientSecret,
@Nullable @Named("che.oauth.github.redirecturis") String[] redirectUris,
@Nullable @Named("che.oauth.github.authuri") String authUri,
@Nullable @Named("che.oauth.github.tokenuri") String tokenUri)
throws IOException {
if (!isNullOrEmpty(clientId)
&& !isNullOrEmpty(clientSecret)
&& !isNullOrEmpty(authUri)
&& !isNullOrEmpty(tokenUri)
&& redirectUris != null
&& redirectUris.length != 0) {
configure(
clientId, clientSecret, redirectUris, authUri, tokenUri, new MemoryDataStoreFactory());
}
}
示例10: main
import com.google.api.client.util.store.MemoryDataStoreFactory; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
if (CLIENT_ID.equals("INSERT_CLIENT_ID_HERE")
|| CLIENT_SECRET.equals("INSERT_CLIENT_SECRET_HERE")) {
throw new IllegalArgumentException("Please input your client IDs or secret. "
+ "See https://console.developers.google.com/project");
}
// It is highly recommended that you use a credential store in your
// application to store a per-user Credential.
// See: https://developers.google.com/api-client-library/java/google-api-java-client/oauth2#data_store
DataStoreFactory storeFactory = new MemoryDataStoreFactory();
// Authorize and store your credential.
authorize(storeFactory, USER_ID);
// Create a DfpSession from the credential store. You will typically do this
// in a servlet interceptor for a web application or per separate thread
// of your offline application.
DfpSession dfpSession = createDfpSession(storeFactory, USER_ID);
DfpServices dfpServices = new DfpServices();
runExample(dfpServices, dfpSession);
}
示例11: WSO2OAuthAuthenticator
import com.google.api.client.util.store.MemoryDataStoreFactory; //导入依赖的package包/类
@Inject
public WSO2OAuthAuthenticator(
@Nullable @Named("oauth.wso2.clientid") String clientId,
@Nullable @Named("oauth.wso2.clientsecret") String clientSecret,
@Nullable @Named("oauth.wso2.redirecturis") String[] redirectUris,
@Nullable @Named("oauth.wso2.authuri") String authUri,
@Nullable @Named("oauth.wso2.tokenuri") String tokenUri,
@Nullable @Named("oauth.wso2.useruri") String userUri)
throws IOException {
this.userUri = userUri;
if (!isNullOrEmpty(clientId)
&& !isNullOrEmpty(clientSecret)
&& !isNullOrEmpty(authUri)
&& !isNullOrEmpty(tokenUri)
&& redirectUris != null
&& redirectUris.length != 0) {
configure(
clientId,
clientSecret,
redirectUris,
authUri,
tokenUri,
new MemoryDataStoreFactory(),
singletonList(SCOPE));
}
}
示例12: GoogleOAuthAuthenticator
import com.google.api.client.util.store.MemoryDataStoreFactory; //导入依赖的package包/类
@Inject
public GoogleOAuthAuthenticator(
@Nullable @Named("oauth.google.clientid") String clientId,
@Nullable @Named("oauth.google.clientsecret") String clientSecret,
@Nullable @Named("oauth.google.redirecturis") String[] redirectUris,
@Nullable @Named("oauth.google.authuri") String authUri,
@Nullable @Named("oauth.google.tokenuri") String tokenUri)
throws IOException {
if (!isNullOrEmpty(clientId)
&& !isNullOrEmpty(clientSecret)
&& redirectUris != null
&& redirectUris.length != 0) {
configure(
new GoogleAuthorizationCodeFlow.Builder(
new NetHttpTransport(),
new JacksonFactory(),
new GoogleClientSecrets()
.setWeb(
new GoogleClientSecrets.Details()
.setClientId(clientId)
.setClientSecret(clientSecret)
.setRedirectUris(Arrays.asList(redirectUris))
.setAuthUri(authUri)
.setTokenUri(tokenUri)),
Arrays.asList(
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile"))
.setDataStoreFactory(new MemoryDataStoreFactory())
.setApprovalPrompt("auto")
.setAccessType("online")
.build(),
Arrays.asList(redirectUris));
}
}
示例13: MicrosoftOauthAuthenticator
import com.google.api.client.util.store.MemoryDataStoreFactory; //导入依赖的package包/类
@Inject
public MicrosoftOauthAuthenticator(
@Nullable @Named("oauth.microsoft.clientid") String clientId,
@Nullable @Named("oauth.microsoft.clientsecret") String clientSecret,
@Nullable @Named("oauth.microsoft.redirecturis") String[] redirectUris,
@Nullable @Named("oauth.microsoft.authuri") String authUri,
@Nullable @Named("oauth.microsoft.tokenuri") String tokenUri,
@Nullable @Named("oauth.microsoft.useruri") String userUri)
throws IOException {
if (!isNullOrEmpty(clientId)
&& !isNullOrEmpty(clientSecret)
&& !isNullOrEmpty(authUri)
&& !isNullOrEmpty(tokenUri)
&& !isNullOrEmpty(userUri)
&& redirectUris != null
&& redirectUris.length != 0) {
configure(
new MicrosoftAuthorizationCodeFlow.Builder(
BearerToken.authorizationHeaderAccessMethod(),
new NetHttpTransport(),
new JacksonFactory(),
new GenericUrl(tokenUri),
new MicrosoftParametersAuthentication(clientSecret),
clientId,
authUri)
.setScopes(Arrays.asList("vso.code_manage", "vso.code_status"))
.setDataStoreFactory(new MemoryDataStoreFactory())
.build(),
Arrays.asList(redirectUris));
}
this.userUri = userUri;
}
示例14: createOAuth2Credentials
import com.google.api.client.util.store.MemoryDataStoreFactory; //导入依赖的package包/类
/**
* Creates an {@link OAuth2Credentials} object that can be used by any of the servlets.
*
* Throws an {@throws IOException} when no client ID or secret found in secrets.properties
*/
static OAuth2Credentials createOAuth2Credentials(SessionConfiguration config) throws IOException {
return new OAuth2Credentials.Builder()
.setCredentialDataStoreFactory(MemoryDataStoreFactory.getDefaultInstance())
.setRedirectUri(config.getRedirectUri())
.setScopes(config.getScopes())
.setClientSecrets(config.getClientId(), config.getClientSecret())
.build();
}
示例15: getInMemoryDatastore
import com.google.api.client.util.store.MemoryDataStoreFactory; //导入依赖的package包/类
public DataStore<StoredCredential> getInMemoryDatastore() {
if (inmemoryDatastore == null) {
try {
inmemoryDatastore = MemoryDataStoreFactory.getDefaultInstance().getDataStore("ListableMemoryCredentialStore");
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
}
return inmemoryDatastore;
}