本文整理汇总了Java中oauth.signpost.basic.DefaultOAuthProvider类的典型用法代码示例。如果您正苦于以下问题:Java DefaultOAuthProvider类的具体用法?Java DefaultOAuthProvider怎么用?Java DefaultOAuthProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultOAuthProvider类属于oauth.signpost.basic包,在下文中一共展示了DefaultOAuthProvider类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRequestToken
import oauth.signpost.basic.DefaultOAuthProvider; //导入依赖的package包/类
/**
* This method request a request token and saves the received authUrl in the
* global variable
*
* @return true if success; false otherwise
*/
public ResponseCode getRequestToken() {
logger.entry();
if (isAuthorized) {
return logger.exit(ResponseCode.APPLICATION_ALREADY_AUTHORIZED);
}
mProvider = new DefaultOAuthProvider(mServer.getRequestUrl(), mServer.getAccessUrl(),
mServer.getAuthorizationUrl());
try {
authUrl = mProvider.retrieveRequestToken(mConsumer, "http://studip-client.danner-web.de/callback");
} catch (OAuthMessageSignerException | OAuthNotAuthorizedException | OAuthExpectationFailedException
| OAuthCommunicationException e) {
logger.debug("Unable to fetch oauth_request_token");
return logger.exit(ResponseCode.SERVER_NOT_REACHABLE);
}
return logger.exit(ResponseCode.SUCCESS);
}
示例2: startAuthentication
import oauth.signpost.basic.DefaultOAuthProvider; //导入依赖的package包/类
/**
* Starts the OAuth authentication flow.
*/
public synchronized void startAuthentication(String accountId) {
WithingsAccount withingsAccount = getAccount(accountId);
if (withingsAccount == null) {
logger.warn("Couldn't find Credentials of Account '{}'. Please check openhab.cfg or withings.cfg.", accountId);
return;
}
OAuthConsumer consumer = withingsAccount.createConsumer();
provider = new DefaultOAuthProvider(OAUTH_REQUEST_TOKEN_ENDPOINT,
OAUTH_ACCESS_TOKEN_ENDPOINT_URL, OAUTH_AUTHORIZE_ENDPOINT_URL);
try {
String url = provider.retrieveRequestToken(consumer, this.redirectUrl);
printSetupInstructions(url);
} catch (OAuthException ex) {
logger.error(ex.getMessage(), ex);
printAuthenticationFailed(ex);
}
}
示例3: Twitter_Handler
import oauth.signpost.basic.DefaultOAuthProvider; //导入依赖的package包/类
public Twitter_Handler(Activity context, String consumerKey,
String secretKey) {
this.context = context;
twitterObj = new TwitterFactory().getInstance();
mSession = new TwitterSession(context);
mProgressDlg = new ProgressDialog(context);
mProgressDlg.requestWindowFeature(Window.FEATURE_NO_TITLE);
mConsumerKey = consumerKey;
mSecretKey = secretKey;
mHttpOauthConsumer = new CommonsHttpOAuthConsumer(mConsumerKey,mSecretKey);
String request_url = TWITTER_REQUEST_URL;
String access_token_url = TWITTER_ACCESS_TOKEN_URL;
String authorize_url = TWITTER_AUTHORZE_URL;
mHttpOauthprovider = new DefaultOAuthProvider(request_url,
access_token_url, authorize_url);
mAccessToken = mSession.getAccessToken();
configureToken();
}
示例4: TwitterApp
import oauth.signpost.basic.DefaultOAuthProvider; //导入依赖的package包/类
private TwitterApp(Context context, String consumerKey, String secretKey) {
this.context = context;
mTwitter = new TwitterFactory().getInstance();
mSession = new TwitterSession(context);
mProgressDlg = new ProgressDialog(context);
mProgressDlg.requestWindowFeature(Window.FEATURE_NO_TITLE);
mConsumerKey = consumerKey;
mSecretKey = secretKey;
mHttpOauthConsumer = new CommonsHttpOAuthConsumer(mConsumerKey, mSecretKey);
mHttpOauthprovider = new DefaultOAuthProvider("https://api.twitter.com/oauth/request_token ",
"https://api.twitter.com/oauth/access_token",
"https://api.twitter.com/oauth/authorize");
mAccessToken = mSession.getAccessToken();
configureToken();
}
示例5: startAuthentication
import oauth.signpost.basic.DefaultOAuthProvider; //导入依赖的package包/类
/**
* Starts the OAuth authentication flow.
*/
public synchronized void startAuthentication(String accountId) {
WithingsAccount withingsAccount = getAccount(accountId);
if (withingsAccount == null) {
logger.warn("Couldn't find Credentials of Account '{}'. Please check openhab.cfg or withings.cfg.",
accountId);
return;
}
OAuthConsumer consumer = withingsAccount.createConsumer();
provider = new DefaultOAuthProvider(OAUTH_REQUEST_TOKEN_ENDPOINT, OAUTH_ACCESS_TOKEN_ENDPOINT_URL,
OAUTH_AUTHORIZE_ENDPOINT_URL);
try {
String url = provider.retrieveRequestToken(consumer, this.redirectUrl);
printSetupInstructions(url);
} catch (OAuthException ex) {
logger.error(ex.getMessage(), ex);
printAuthenticationFailed(ex);
}
}
示例6: onCreate
import oauth.signpost.basic.DefaultOAuthProvider; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//设置屏幕没有标题栏
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.welcome);
webInstance = this;
mContext = getApplicationContext();
accessInfo = InfoHelper.getAccessInfo(mContext);
//生成consumer,consumer代表我们自己开发的应用JSU
consumer = new CommonsHttpOAuthConsumer(ConstantsUtils.CONSUMER_KEY,
ConstantsUtils.CONSUMER_SECRET);
//生成provider,provider代表新浪微博,传入认证需要的三个地址
provider = new DefaultOAuthProvider(
UrlUtils.REQUEST_TOKEN,
UrlUtils.ACCESS_TOKEN,
UrlUtils.AUTHORIZE);
}
示例7: oAuthProvider
import oauth.signpost.basic.DefaultOAuthProvider; //导入依赖的package包/类
@Provides public static OAuthProvider oAuthProvider()
{
return new DefaultOAuthProvider(
BASE_OAUTH_URL + "request_token",
BASE_OAUTH_URL + "access_token",
BASE_OAUTH_URL + "authorize");
}
示例8: createOAuthService
import oauth.signpost.basic.DefaultOAuthProvider; //导入依赖的package包/类
private void createOAuthService() {
mOAuthConsumer = new DefaultOAuthConsumer(mApiKey,mApiSecret);
mOAuthProvider = new DefaultOAuthProvider(
"https://api.discogs.com/oauth/request_token", "https://api.discogs.com/oauth/access_token",
"https://www.discogs.com/oauth/authorize");
mOAuthProvider.setListener(new DiscogsOauthProviderListener());
}
示例9: OAuthUtil
import oauth.signpost.basic.DefaultOAuthProvider; //导入依赖的package包/类
public OAuthUtil(String key, String secret) {
provider = new DefaultOAuthProvider(
"https://cacoo.com/oauth/request_token",
"https://cacoo.com/oauth/access_token",
"https://cacoo.com/oauth/authorize");
consumer = new DefaultOAuthConsumer(key, secret);
}
示例10: createProvider
import oauth.signpost.basic.DefaultOAuthProvider; //导入依赖的package包/类
public static OAuthProvider createProvider() {
return new DefaultOAuthProvider(
BASE_OAUTH_URL + "request_token",
BASE_OAUTH_URL + "access_token",
BASE_OAUTH_URL + "authorize");
}
示例11: OAuth
import oauth.signpost.basic.DefaultOAuthProvider; //导入依赖的package包/类
private OAuth(ServiceInfo info) {
this.info = info;
provider = new DefaultOAuthProvider(info.requestTokenURL, info.accessTokenURL, info.authorizationURL);
provider.setOAuth10a(true);
}
示例12: buildOAuthProvider
import oauth.signpost.basic.DefaultOAuthProvider; //导入依赖的package包/类
/**
* Create an {@link OAuthProvider} for the IS24-Webservice.
* <p>
* Different implementations of {@link AbstractClient} may create different
* {@link OAuthProvider} objects.
*
* @param apiBaseUrl
* URL of the IS24-Webservice
*
* @return
* an instance of {@link OAuthProvider} for the provided URL
*/
protected OAuthProvider buildOAuthProvider( String apiBaseUrl )
{
return new DefaultOAuthProvider(
apiBaseUrl + "/security/oauth/request_token",
apiBaseUrl + "/security/oauth/access_token",
apiBaseUrl + "/security/oauth/confirm_access" );
}
示例13: onCreate
import oauth.signpost.basic.DefaultOAuthProvider; //导入依赖的package包/类
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
this.consumer = new DefaultOAuthConsumer(CONSUMER_KEY,
CONSUMER_SECRET);
this.provider = new DefaultOAuthProvider(
TUMBLR_REQUEST_TOKEN_URL, TUMBLR_ACCESS_TOKEN_URL,
TUMBLR_AUTHORIZE_URL);
}
示例14: main
import oauth.signpost.basic.DefaultOAuthProvider; //导入依赖的package包/类
/**
* Main function.
*
* @param args
* command line arguments
*/
public static void main( String[] args ) throws Exception
{
OAuthConsumer consumer =
new DefaultOAuthConsumer( "testzugang-import-api-maklermanagerKey", "VXyCmVpjR4GQVCVBf33T" );
OAuthProvider provider =
new DefaultOAuthProvider( "http://sandbox.immobilienscout24.de/restapi/security/oauth/request_token",
"http://sandbox.immobilienscout24.de/restapi/security/oauth/access_token",
"http://sandbox.immobilienscout24.de/restapi/security/oauth/confirm_access" );
LOGGER.info( "Fetching request token..." );
String authUrl =
provider.retrieveRequestToken( consumer, "http://www.google.de" );
String requestToken = consumer.getToken();
String requestTokenSecret = consumer.getTokenSecret();
LOGGER.info( "Request token: "+requestToken );
LOGGER.info( "Token secret: "+requestTokenSecret );
LOGGER.info( "Now visit:\n"+authUrl
+"\n... and grant this app authorization" );
LOGGER.info( "Enter the verification code and hit ENTER when you're done:" );
BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
String verificationCode = br.readLine();
LOGGER.info( "Fetching access token..." );
provider.retrieveAccessToken( consumer, verificationCode.trim() );
String accessToken = consumer.getToken();
String accessTokenSecret = consumer.getTokenSecret();
LOGGER.info( "Access token: "+accessToken );
LOGGER.info( "Token secret: "+accessTokenSecret );
//LOGGER.debug( "first call" );
requestObjectApi( consumer );
//LOGGER.debug( "second call" );
requestObjectApi( consumer );
//LOGGER.debug( "third call" );
OAuthConsumer consumer2 =
new DefaultOAuthConsumer( "testzugang-import-api-maklermanagerKey", "VXyCmVpjR4GQVCVBf33T" );
consumer2.setTokenWithSecret( accessToken, accessTokenSecret );
requestObjectApi( consumer2 );
}