本文整理汇总了Java中net.dean.jraw.http.oauth.OAuthException类的典型用法代码示例。如果您正苦于以下问题:Java OAuthException类的具体用法?Java OAuthException怎么用?Java OAuthException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OAuthException类属于net.dean.jraw.http.oauth包,在下文中一共展示了OAuthException类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: run
import net.dean.jraw.http.oauth.OAuthException; //导入依赖的package包/类
@Override
public void run() {
Credentials creds = Credentials.userless(
reddigramBot.config().clientId(),
reddigramBot.config().clientSecret(),
reddigramBot.deviceId()
);
OAuthData data;
try {
data = reddigramBot.client().getOAuthHelper().easyAuth(creds);
} catch (OAuthException ex) {
// Oh no! Complain to owner and shut down
reddigramBot.log("Couldn't authenticate the bot! Shutting down...");
ex.printStackTrace();
reddigramBot.sendToOwner("Couldn't complete OAuth with Reddit (message=" + ex.getMessage() + ")");
return;
}
reddigramBot.client().authenticate(data);
}
开发者ID:mkotb,项目名称:Reddigram,代码行数:22,代码来源:OAuthTask.java
示例2: scanReddit
import net.dean.jraw.http.oauth.OAuthException; //导入依赖的package包/类
public ArrayList<String> scanReddit(AuthHelper helper, ArrayList<String> links) throws NetworkException, OAuthException {
RedditClient redditClient = helper.getRedditClient();
SubredditPaginator doto = new SubredditPaginator(redditClient,"dota2");
doto.setLimit(100);
doto.setTimePeriod(TimePeriod.ALL);
doto.setSorting(Sorting.NEW);
Listing<Submission> submissions = doto.next();
String linkUrl = null;
System.out.println("OK2");
for(Submission s : submissions){
linkUrl = s.getUrl();
System.out.println(linkUrl);
if(linkUrl.contains("oddshot") && !links.contains(linkUrl)){
Scanner.submissionList.add(s);
links.add(linkUrl);
}
}
return links;
}
开发者ID:ashwinswaroop,项目名称:YouTubeBot,代码行数:20,代码来源:Scanner.java
示例3: onPastaCommand
import net.dean.jraw.http.oauth.OAuthException; //导入依赖的package包/类
@Command(aliases = {"pasta", "copypasta"}, description = "Gets a random copypasta from /r/copypasta.", usage = "pasta")
public static String onPastaCommand(String[] args, IMessage message) throws OAuthException, RateLimitException, DiscordException, MissingPermissionsException {
Listing<Submission> copypasta = null;
RedditClient redditClient;
try {
redditClient = Reddit.getRedditClient();
if (!redditClient.isAuthenticated()) {
Reddit.authReddit();
}
FluentRedditClient fluent = new FluentRedditClient(redditClient);
copypasta = fluent.subreddit("copypasta").fetch();
} catch (NetworkException | NullPointerException e) {
Reddit.authReddit();
onPastaCommand(args, message);
}
System.out.println("Serving some pasta.");
Random random = new Random();
if (copypasta != null) {
Submission pasta = copypasta.get(random.nextInt(copypasta.size()));
if (args.length > 0) {
message.delete();
return "Too many arguments! Use `~help` to get usages.";
} else if (args.length == 0) {
message.delete();
return StringUtils.abbreviate((":spaghetti: " + "**" + pasta.getTitle() + "**\n" + pasta.getSelftext()), 2000);
}
}
// Something went wrong, display error message
message.delete();
return "An error occurred, please try again later.";
}
开发者ID:nbd9,项目名称:PastaBot,代码行数:34,代码来源:PastaCommand.java
示例4: onJokeCommand
import net.dean.jraw.http.oauth.OAuthException; //导入依赖的package包/类
@Command(aliases = {"joke", "prank"}, description = "Gets a random joke from /r/jokes.", usage = "joke")
public static String onJokeCommand(String[] args, IMessage message) throws OAuthException, RateLimitException, DiscordException, MissingPermissionsException {
Listing<Submission> jokes = null;
RedditClient redditClient;
try {
redditClient = Reddit.getRedditClient();
if (!redditClient.isAuthenticated()) {
Reddit.authReddit();
}
FluentRedditClient fluent = new FluentRedditClient(redditClient);
jokes = fluent.subreddit("jokes").fetch();
} catch (NetworkException | NullPointerException e) {
Reddit.authReddit();
onJokeCommand(args, message);
}
Random random = new Random();
System.out.println("Telling a bad joke.");
if (jokes != null) {
Submission joke = jokes.get(random.nextInt(jokes.size()));
if (args.length > 0) {
message.delete();
return "Too many arguments! Use `~help` to get usages.";
} else if (args.length == 0) {
message.delete();
return StringUtils.abbreviate((":rofl: " + "**" + joke.getTitle() + "**\n" + joke.getSelftext()), 2000);
}
}
// Something went wrong, display error message.
message.delete();
return "An error occurred, please try again";
}
开发者ID:nbd9,项目名称:PastaBot,代码行数:35,代码来源:JokeCommand.java
示例5: main
import net.dean.jraw.http.oauth.OAuthException; //导入依赖的package包/类
public static void main(String[] args) throws OAuthException {
IDiscordClient client = Discord.createClient(Keys.DiscordBotToken, true);
EventDispatcher dispatcher = client.getDispatcher(); // Gets the EventDispatcher instance for this client instance
dispatcher.registerListener(new InterfaceListener()); // Registers the IListener example class from above
CommandHandler handler = new Discord4JHandler(client);
handler.setDefaultPrefix("~");
handler.registerCommand(new PastaCommand());
handler.registerCommand(new JokeCommand());
handler.registerCommand(new KahootCommand());
handler.registerCommand(new HelpCommand(handler));
}
开发者ID:nbd9,项目名称:PastaBot,代码行数:12,代码来源:Main.java
示例6: ScraperBot
import net.dean.jraw.http.oauth.OAuthException; //导入依赖的package包/类
public ScraperBot() throws OAuthException {
UserAgent agent = UserAgent.of("script", "io.github.<username>", "v0.1", "<username>");
client = new RedditClient(agent);
Credentials cred = Credentials.script("<username>", "<password>", "<public key>", "<private key>");
OAuthData data = client.getOAuthHelper().easyAuth(cred);
client.authenticate(data);
posts = new HashMap<>();
}
开发者ID:nikmanG,项目名称:DailyProgrammer,代码行数:12,代码来源:ScraperBot.java
示例7: main
import net.dean.jraw.http.oauth.OAuthException; //导入依赖的package包/类
public static void main(String[] args) {
try {
ScraperBot sb = new ScraperBot();
sb.getPosts(sb.getHeadlines(100));
SimpleMarkdown sm = new SimpleMarkdown();
sm.saveData(posts);
//TODO: scanner for searching
} catch (OAuthException | IOException e) {
e.printStackTrace();
}
}
开发者ID:nikmanG,项目名称:DailyProgrammer,代码行数:15,代码来源:ScraperBot.java
示例8: handleOAuthSuccess
import net.dean.jraw.http.oauth.OAuthException; //导入依赖的package包/类
@Background
protected void handleOAuthSuccess(String url) {
try {
OAuthData resp = this.helper.onUserChallenge(url, this.credentials);
this.manager.getClient().authenticate(resp);
this.handleSuccess();
} catch (OAuthException ex) {
this.handleError(ex.getMessage());
}
}
开发者ID:AlbinoDrought,项目名称:party-reader,代码行数:11,代码来源:LoginActivity.java
示例9: init
import net.dean.jraw.http.oauth.OAuthException; //导入依赖的package包/类
public void init() {
log.info("got here");
try {
UserAgent myUserAgent = UserAgent.of("desktop", "com.flowchat", "v0.1", "dessalines");
redditClient = new RedditClient(myUserAgent);
Credentials credentials = Credentials.script(DataSources.PROPERTIES.getProperty("reddit_username"),
DataSources.PROPERTIES.getProperty("reddit_password"),
DataSources.PROPERTIES.getProperty("reddit_client_id"),
DataSources.PROPERTIES.getProperty("reddit_client_secret"));
OAuthData authData = redditClient.getOAuthHelper().easyAuth(credentials);
redditClient.authenticate(authData);
} catch (OAuthException e) {
e.printStackTrace();
}
}
开发者ID:dessalines,项目名称:flowchat,代码行数:16,代码来源:RedditImporter.java
示例10: authenticateUrl
import net.dean.jraw.http.oauth.OAuthException; //导入依赖的package包/类
/**
* Gets the deferred observable used for authenticating using the given url.
*
* @param url the url to authenticate with
* @return the deferred observable used for authenticating the given url
*/
public Observable<String> authenticateUrl(String url) {
return Observable.defer(() -> {
try {
return Observable.just(mJrawHelper.authenticateUrl(url));
} catch (OAuthException e) {
return Observable.error(e);
}
});
}
开发者ID:JotraN,项目名称:Reader,代码行数:16,代码来源:DataManager.java
示例11: authenticateToken
import net.dean.jraw.http.oauth.OAuthException; //导入依赖的package包/类
/**
* Gets the deferred observable used for authenticating using the given
* refresh token.
*
* @param refreshToken the refresh toke to authenticate with
* @return the deferred observable used for authenticating the given
* refresh token
*/
public Observable<Boolean> authenticateToken(String refreshToken) {
return Observable.defer(() -> {
try {
return Observable.just(mJrawHelper.authenticateToken(refreshToken));
} catch (OAuthException e) {
return Observable.error(e);
}
});
}
开发者ID:JotraN,项目名称:Reader,代码行数:18,代码来源:DataManager.java
示例12: authenticate
import net.dean.jraw.http.oauth.OAuthException; //导入依赖的package包/类
public AuthHelper authenticate() throws NetworkException, OAuthException{
AuthHelper helper = new AuthHelper();
UserAgent myUserAgent = UserAgent.of("desktop", "YouTubeBot", "0.1", "-YouTubeBot-");
RedditClient redditClient = new RedditClient(myUserAgent);
Credentials credentials = Credentials.script("-YouTubeBot-", "Ash3win#", "WnBQphrJ2jWY5A", "bJmaYXBDHUNfPGRpSEUPHOtLrIk");
OAuthData authData = redditClient.getOAuthHelper().easyAuth(credentials);
redditClient.authenticate(authData);
helper.setCredentials(credentials);
helper.setRedditClient(redditClient);
return(helper);
}
开发者ID:ashwinswaroop,项目名称:YouTubeBot,代码行数:12,代码来源:Authenticator.java
示例13: authReddit
import net.dean.jraw.http.oauth.OAuthException; //导入依赖的package包/类
public static RedditClient authReddit() throws OAuthException {
System.out.println("Reauthenticating Reddit");
Credentials credentials = Credentials.script("DiscordPastaBot", Keys.RedditPass, Keys.RedditID, Keys.RedditSecret);
redditClient.authenticate(redditClient.getOAuthHelper().easyAuth(credentials));
return redditClient;
}
开发者ID:nbd9,项目名称:PastaBot,代码行数:7,代码来源:Reddit.java
示例14: authenticate
import net.dean.jraw.http.oauth.OAuthException; //导入依赖的package包/类
private static OAuthData authenticate() throws NetworkException, OAuthException {
return redditClient.getOAuthHelper().easyAuth(credentials);
}
开发者ID:paul-io,项目名称:momo-2,代码行数:4,代码来源:RedditEventListener.java
示例15: authenticateToken
import net.dean.jraw.http.oauth.OAuthException; //导入依赖的package包/类
/**
* Authenticates the client using the given refresh token.
*
* @param refreshToken the refresh token to use
* @return true if the authentication was successful
* @throws OAuthException if there was a problem authenticating
*/
public boolean authenticateToken(String refreshToken) throws OAuthException {
mOAuthHelper.setRefreshToken(refreshToken);
OAuthData oAuthData = mOAuthHelper.refreshToken(mCredentials);
mRedditClient.authenticate(oAuthData);
return true;
}
开发者ID:JotraN,项目名称:Reader,代码行数:14,代码来源:JrawReaderHelper.java
示例16: authenticateUrl
import net.dean.jraw.http.oauth.OAuthException; //导入依赖的package包/类
/**
* Authenticates the client using the given url.
*
* @param url the final url retrieved after the gave permission
* @return the refresh token retrieved upon authentication
* @throws OAuthException if there was a problem authenticating
*/
public String authenticateUrl(String url) throws OAuthException {
OAuthData oAuthData = mOAuthHelper.onUserChallenge(url, mCredentials);
mRedditClient.authenticate(oAuthData);
return oAuthData.getRefreshToken();
}
开发者ID:JotraN,项目名称:Reader,代码行数:13,代码来源:JrawReaderHelper.java
注:本文中的net.dean.jraw.http.oauth.OAuthException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论