本文整理了Java中com.github.philippheuer.credentialmanager.domain.OAuth2Credential
类的一些代码示例,展示了OAuth2Credential
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OAuth2Credential
类的具体详情如下:
包路径:com.github.philippheuer.credentialmanager.domain.OAuth2Credential
类名称:OAuth2Credential
暂无
代码示例来源:origin: twitch4j/twitch4j
Request request = new Request.Builder()
.url("https://id.twitch.tv/oauth2/validate")
.header("Authorization", "OAuth " + credential.getAccessToken())
.build();
OAuth2Credential newCredential = new OAuth2Credential(credential.getIdentityProvider(), credential.getAccessToken(), credential.getRefreshToken(), userId, userName, null, scopes);
代码示例来源:origin: twitch4j/twitch4j
@Override
public void onConnected(WebSocket ws, Map
log.info("Connecting to Twitch IRC {}", webSocketServer);
// if credentials is null, it will automatically disconnect
if (!chatCredential.isPresent()) {
log.error("Can't find credentials for the chat account!");
disconnect();
return; // do not continue script
}
// acquire capabilities
sendCommand("CAP REQ :twitch.tv/tags twitch.tv/commands twitch.tv/membership");
sendCommand("CAP END");
// sign in
sendCommand(String.format("pass oauth:%s", chatCredential.get().getAccessToken()));
sendCommand(String.format("nick %s", chatCredential.get().getUserName()));
// Join defined channels, in case we reconnect or weren't connected yet when we called joinChannel
if (!channelCache.isEmpty()) {
for (String channel : channelCache.keySet()) {
sendCommand("join #" + channel);
}
}
// then join to own channel - required for sending or receiving whispers
if (chatCredential.get().getUserName() != null) {
sendCommand("join #" + chatCredential.get().getUserName());
} else {
log.warn("Chat: The whispers feature is currently not available because the provided credential does not hold information about the user. Please check the documentation on how to pass the token to the credentialManager where it will be enriched with the required information.");
}
// Connection Success
cOnnectionState= TMIConnectionState.CONNECTED;
}
代码示例来源:origin: twitch4j/twitch4j
@Override
public Response intercept(Interceptor.Chain chain) throws IOException {
Request original = chain.request();
Request.Builder requestBuilder = original
.newBuilder()
.header("Client-Id", clientId);
if (credential != null) {
requestBuilder.header("Authorization", "OAuth " + credential.getAccessToken());
}
Request request = requestBuilder.build();
return chain.proceed(request);
}
})
代码示例来源:origin: twitch4j/twitch4j
/**
* Gets the OAuth Credential for integration tests
*
* @return OAuth2Credential
*/
public static OAuth2Credential getCredential() {
return new OAuth2Credential("twitch", System.getenv("TWITCH_AUTH_TOKEN"));
}
代码示例来源:origin: twitch4j/twitch4j
/**
* Sends a user a private message
*
* @param targetUser username
* @param message message
*/
public void sendPrivateMessage(String targetUser, String message) {
log.debug("Adding private message for user [{}] with content [{}] to the queue.", targetUser, message);
ircCommandQueue.add(String.format("PRIVMSG #%s /w %s %s", chatCredential.get().getUserName(), targetUser, message));
}
代码示例来源:origin: twitch4j/twitch4j
/**
* Event Listener: Anyone cheers on a specified channel.
*
* @param credential Credential (any)
* @param userId Target User Id
*/
public void listenForCheerEvents(OAuth2Credential credential, Long userId) {
PubSubRequest request = new PubSubRequest();
request.setType(PubSubType.LISTEN);
request.setNonce(UUID.randomUUID().toString());
request.getData().put("auth_token", credential.getAccessToken());
request.getData().put("topics", Arrays.asList("channel-bits-events-v1." + userId.toString()));
listenOnTopic(request);
}
代码示例来源:origin: twitch4j/twitch4j
/**
* Gets the OAuth Credential for integration tests
*
* @return OAuth2Credential
*/
public static OAuth2Credential getGraphQLCredential() {
return new OAuth2Credential("twitch", System.getenv("TWITCH_AUTH_GQL_TOKEN"));
}
代码示例来源:origin: twitch4j/twitch4j
} else if(this.chatCredential.get().getUserName() == null) {
log.info("TwitchChat: AccessToken does not contain any user information, fetching using the CredentialManager ...");
代码示例来源:origin: twitch4j/twitch4j
/**
* Event Listener: Anyone subscribes (first month), resubscribes (subsequent months), or gifts a subscription to a channel.
*
* @param credential Credential (for targetUserId, scope: channel_subscriptions)
* @param userId Target User Id
*/
public void listenForSubscriptionEvents(OAuth2Credential credential, Long userId) {
PubSubRequest request = new PubSubRequest();
request.setType(PubSubType.LISTEN);
request.setNonce(UUID.randomUUID().toString());
request.getData().put("auth_token", credential.getAccessToken());
request.getData().put("topics", Arrays.asList("channel-subscribe-events-v1." + userId.toString()));
listenOnTopic(request);
}
代码示例来源:origin: twitch4j/twitch4j
/**
* Gets the OAuth Credential for integration tests
*
* @return OAuth2Credential
*/
public static OAuth2Credential getCredential() {
return new OAuth2Credential("twitch", System.getenv("TWITCH_AUTH_TOKEN"));
}
代码示例来源:origin: twitch4j/twitch4j
/**
* Event Listener: Anyone whispers the specified user.
*
* @param credential Credential (for targetUserId, scope: whispers:read)
* @param userId Target User Id
*/
public void listenForWhisperEvents(OAuth2Credential credential, Long userId) {
PubSubRequest request = new PubSubRequest();
request.setType(PubSubType.LISTEN);
request.setNonce(UUID.randomUUID().toString());
request.getData().put("auth_token", credential.getAccessToken());
request.getData().put("topics", Arrays.asList("whispers." + userId.toString()));
listenOnTopic(request);
}
代码示例来源:origin: twitch4j/twitch4j
/**
* Gets the OAuth Credential for integration tests
*
* @return OAuth2Credential
*/
public static OAuth2Credential getCredential() {
return new OAuth2Credential("twitch", System.getenv("TWITCH_AUTH_TOKEN"));
}
代码示例来源:origin: twitch4j/twitch4j
/**
* Event Listener: Anyone makes a purchase on a channel.
*
* @param credential Credential (any)
* @param userId Target User Id
*/
public void listenForCommerceEvents(OAuth2Credential credential, Long userId) {
PubSubRequest request = new PubSubRequest();
request.setType(PubSubType.LISTEN);
request.setNonce(UUID.randomUUID().toString());
request.getData().put("auth_token", credential.getAccessToken());
request.getData().put("topics", Arrays.asList("channel-commerce-events-v1." + userId.toString()));
listenOnTopic(request);
}
代码示例来源:origin: twitch4j/twitch4j
/**
* Gets the OAuth Credential for integration tests
*
* @return OAuth2Credential
*/
public static OAuth2Credential getCredential() {
return new OAuth2Credential("twitch", System.getenv("TWITCH_AUTH_TOKEN"));
}
代码示例来源:origin: twitch4j/twitch4j
/**
* Create Clips
*/
@Test
@DisplayName("Create Clip")
@Disabled
public void createClipTest() {
// TestCase
CreateClipList clipData = testUtils.getTwitchHelixClient().createClip(testUtils.getCredential().getAccessToken(), "23161357", null).execute();
// Validate
clipData.getData().forEach(clip -> {
System.out.println("Created Clip with ID: " + clip.getId());
});
}
代码示例来源:origin: twitch4j/twitch4j
/**
* Gets the OAuth Credential for integration tests
*
* @return OAuth2Credential
*/
public static OAuth2Credential getCredential() {
return new OAuth2Credential("twitch", System.getenv("TWITCH_AUTH_TOKEN"));
}
代码示例来源:origin: twitch4j/twitch4j
/**
* Update user description
*/
@Test
@DisplayName("Update the user description")
public void updateDescription() {
// TestCase
UserList resultList = testUtils.getTwitchHelixClient().updateUser(testUtils.getCredential().getAccessToken(), "Twitch4J IntegrationTest User").execute();
}
代码示例来源:origin: twitch4j/twitch4j
/**
* Test - Twitch Identity Provider
*/
@Test
@DisplayName("Twitch Identity Provider")
public void twitchIdentityProvider() {
// build
CredentialManager credentialManager = CredentialManagerBuilder.builder().build();
// register idp
credentialManager.registerIdentityProvider(new TwitchIdentityProvider("nzymnj7ao06w2u1smp8tqnmmp0rc5f", "g5puvhnijc9w09m8lnaqc1jy1ao78c", "http://localhost:31921/process_oauth2"));
// add credential
Credential credential = new OAuth2Credential("twitch", "*authToken*");
credentialManager.addCredential("twitch", credential);
}
代码示例来源:origin: twitch4j/twitch4j
/**
* Get Bits Leaderboard
*/
@Test
@DisplayName("Fetch the bits leaderboard")
public void getBitsLeaderboard() {
// TestCase
BitsLeaderboard resultList = testUtils.getTwitchHelixClient().getBitsLeaderboard(testUtils.getCredential().getAccessToken(), "10", "all", null, null).execute();
// Test
assertTrue(resultList.getEntries().size() == 0, "That account can't get bits, so it's always a empty list");
}
代码示例来源:origin: twitch4j/twitch4j
@Test
@DisplayName("getSubscribers")
@Disabled // test acc has no subs
public void getSubscribers() {
KrakenSubscriptionList resultList = getTwitchKrakenClient().getChannelSubscribers(AbstractKrakenServiceTest.getCredential().getAccessToken(), 149223493l, null, null, null).execute();
assertTrue(resultList.getSubscriptions().size() > 0, "Didn't find any subscriptions!");
}