本文整理汇总了Java中net.dean.jraw.http.oauth.OAuthData类的典型用法代码示例。如果您正苦于以下问题:Java OAuthData类的具体用法?Java OAuthData怎么用?Java OAuthData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OAuthData类属于net.dean.jraw.http.oauth包,在下文中一共展示了OAuthData类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: userlessAuthentication
import net.dean.jraw.http.oauth.OAuthData; //导入依赖的package包/类
public static Completable userlessAuthentication(
final RedditClient reddit,
final Credentials credentials) {
return Completable.create(new CompletableOnSubscribe() {
@Override
public void subscribe(CompletableEmitter e) throws Exception {
try {
OAuthData oAuthData = reddit.getOAuthHelper().easyAuth(credentials);
reddit.authenticate(oAuthData);
e.onComplete();
} catch (Exception ex) {
e.onError(ex);
}
}
});
}
示例2: userAuthentication
import net.dean.jraw.http.oauth.OAuthData; //导入依赖的package包/类
public static Completable userAuthentication(
final RedditClient reddit,
final Credentials credentials,
final String url) {
return Completable.create(new CompletableOnSubscribe() {
@Override
public void subscribe(CompletableEmitter e) throws Exception {
OAuthHelper oAuthHelper = reddit.getOAuthHelper();
try {
OAuthData oAuthData = oAuthHelper.onUserChallenge(url, credentials);
reddit.authenticate(oAuthData);
AuthenticationManager.get().onAuthenticated(oAuthData);
e.onComplete();
} catch (Exception ex) {
e.onError(ex);
}
}
});
}
示例3: run
import net.dean.jraw.http.oauth.OAuthData; //导入依赖的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);
}
示例4: ScraperBot
import net.dean.jraw.http.oauth.OAuthData; //导入依赖的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<>();
}
示例5: handleOAuthSuccess
import net.dean.jraw.http.oauth.OAuthData; //导入依赖的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());
}
}
示例6: init
import net.dean.jraw.http.oauth.OAuthData; //导入依赖的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();
}
}
示例7: authenticate
import net.dean.jraw.http.oauth.OAuthData; //导入依赖的package包/类
@Override
public boolean authenticate(RedditClient redditClient) {
try {
OAuthData oAuthData = redditClient.getOAuthHelper().easyAuth(getCredentials());
redditClient.authenticate(oAuthData);
} catch (Exception e) {
LOG.error("Could not authenticate: %s", e.getMessage());
return false;
}
return isAuthenticated(redditClient);
}
示例8: authenticate
import net.dean.jraw.http.oauth.OAuthData; //导入依赖的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);
}
示例9: onPostExecute
import net.dean.jraw.http.oauth.OAuthData; //导入依赖的package包/类
@Override
protected void onPostExecute(OAuthData oAuthData) {
if(oAuthData!=null){
redditClient.authenticate(oAuthData);
EventBus.getDefault().post(new FinishLoginActivityEvent(redditClient));
}
}
示例10: onPostExecute
import net.dean.jraw.http.oauth.OAuthData; //导入依赖的package包/类
@Override
protected void onPostExecute(OAuthData oAuthData) {
if(oAuthData!=null){
redditClient.authenticate(oAuthData);
EventBus.getDefault().post(new FinishLoginActivityEvent(redditClient));
} else{
onCancelled();
}
}
示例11: onPostExecute
import net.dean.jraw.http.oauth.OAuthData; //导入依赖的package包/类
@Override
protected void onPostExecute(OAuthData oAuthData) {
//Dismiss old progress dialog
mMaterialDialog.dismiss();
if (oAuthData != null) {
Reddit.appRestart.edit().putBoolean("firststarting", true).apply();
UserSubscriptions.switchAccounts();
d = new MaterialDialog.Builder(Login.this).cancelable(false)
.title(R.string.login_starting)
.progress(true, 0)
.content(R.string.login_starting_desc)
.build();
d.show();
UserSubscriptions.syncSubredditsGetObjectAsync(Login.this);
} else {
//Show a dialog if data is null
MaterialDialog.Builder builder =
new MaterialDialog.Builder(Login.this).title(R.string.err_authentication)
.content(R.string.login_failed_err_decline)
.neutralText(R.string.btn_ok)
.onNeutral(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@Nullable MaterialDialog dialog,
@Nullable DialogAction which) {
Reddit.forceRestart(Login.this, true);
finish();
}
});
builder.show();
}
}
示例12: authenticate
import net.dean.jraw.http.oauth.OAuthData; //导入依赖的package包/类
private static OAuthData authenticate() throws NetworkException, OAuthException {
return redditClient.getOAuthHelper().easyAuth(credentials);
}
示例13: authenticateToken
import net.dean.jraw.http.oauth.OAuthData; //导入依赖的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;
}
示例14: authenticateUrl
import net.dean.jraw.http.oauth.OAuthData; //导入依赖的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();
}