当前位置: 首页>>代码示例>>Java>>正文


Java OAuthData类代码示例

本文整理汇总了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);
            }
        }
    });
}
 
开发者ID:jorgegil96,项目名称:JRAW-Android-Sample,代码行数:17,代码来源:RedditService.java

示例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);
            }
        }
    });
}
 
开发者ID:jorgegil96,项目名称:JRAW-Android-Sample,代码行数:21,代码来源:RedditService.java

示例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);
}
 
开发者ID:mkotb,项目名称:Reddigram,代码行数:22,代码来源:OAuthTask.java

示例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<>();
}
 
开发者ID:nikmanG,项目名称:DailyProgrammer,代码行数:12,代码来源:ScraperBot.java

示例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());
    }
}
 
开发者ID:AlbinoDrought,项目名称:party-reader,代码行数:11,代码来源:LoginActivity.java

示例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();
    }
}
 
开发者ID:dessalines,项目名称:flowchat,代码行数:16,代码来源:RedditImporter.java

示例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);
}
 
开发者ID:sgskinner,项目名称:StashThisBot,代码行数:13,代码来源:OauthServiceImpl.java

示例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);
}
 
开发者ID:ashwinswaroop,项目名称:YouTubeBot,代码行数:12,代码来源:Authenticator.java

示例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));
    }
}
 
开发者ID:haoguanqing,项目名称:Subreddit_Reader,代码行数:8,代码来源:LoginActivity.java

示例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();
    }
}
 
开发者ID:haoguanqing,项目名称:Subreddit_Reader,代码行数:10,代码来源:WelcomeDialog.java

示例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();
    }
}
 
开发者ID:ccrama,项目名称:Slide,代码行数:36,代码来源:Login.java

示例12: authenticate

import net.dean.jraw.http.oauth.OAuthData; //导入依赖的package包/类
private static OAuthData authenticate() throws NetworkException, OAuthException {
	return redditClient.getOAuthHelper().easyAuth(credentials);
}
 
开发者ID:paul-io,项目名称:momo-2,代码行数:4,代码来源:RedditEventListener.java

示例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;
}
 
开发者ID:JotraN,项目名称:Reader,代码行数:14,代码来源:JrawReaderHelper.java

示例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();
}
 
开发者ID:JotraN,项目名称:Reader,代码行数:13,代码来源:JrawReaderHelper.java


注:本文中的net.dean.jraw.http.oauth.OAuthData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。