本文整理汇总了Java中org.scribe.model.Verifier类的典型用法代码示例。如果您正苦于以下问题:Java Verifier类的具体用法?Java Verifier怎么用?Java Verifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Verifier类属于org.scribe.model包,在下文中一共展示了Verifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: authorize
import org.scribe.model.Verifier; //导入依赖的package包/类
public static Auth authorize(Flickr flickr, File authDirectory, String username) throws IOException, SAXException, FlickrException {
AuthStore authStore = new FileAuthStore(authDirectory);
Auth auth = authStore.retrieve(flickr.getPeopleInterface().findByUsername(username).getId());
if (auth != null) {
RequestContext.getRequestContext().setAuth(auth);
return auth;
}
AuthInterface authInterface = flickr.getAuthInterface();
Token accessToken = authInterface.getRequestToken();
String url = authInterface.getAuthorizationUrl(accessToken, Permission.READ);
System.out.println("Please visit the following URL to get your authorization token:");
System.out.println();
System.out.println(url);
System.out.println();
System.out.print("Enter your token: ");
String tokenKey = new Scanner(System.in).nextLine();
Token requestToken = authInterface.getAccessToken(accessToken, new Verifier(tokenKey));
auth = authInterface.checkToken(requestToken);
RequestContext.getRequestContext().setAuth(auth);
authStore.store(auth);
return auth;
}
示例2: getAccessToken
import org.scribe.model.Verifier; //导入依赖的package包/类
@Override
public Token getAccessToken(Token requestToken, Verifier verifier) {
OAuthRequest request = new OAuthRequest(api.getAccessTokenVerb(), api.getAccessTokenEndpoint());
switch (api.getAccessTokenVerb()) {
case POST:
request.addBodyParameter(OAuthConstants.CLIENT_ID, config.getApiKey());
request.addBodyParameter(OAuthConstants.CLIENT_SECRET, config.getApiSecret());
request.addBodyParameter(OAuthConstants.CODE, verifier.getValue());
request.addBodyParameter(OAuthConstants.REDIRECT_URI, config.getCallback());
request.addBodyParameter(GRANT_TYPE, GRANT_TYPE_AUTHORIZATION_CODE);
break;
case GET:
default:
request.addQuerystringParameter(OAuthConstants.CLIENT_ID, config.getApiKey());
request.addQuerystringParameter(OAuthConstants.CLIENT_SECRET, config.getApiSecret());
request.addQuerystringParameter(OAuthConstants.CODE, verifier.getValue());
request.addQuerystringParameter(OAuthConstants.REDIRECT_URI, config.getCallback());
if(config.hasScope()) request.addQuerystringParameter(OAuthConstants.SCOPE, config.getScope());
}
Response response = request.send();
return api.getAccessTokenExtractor().extract(response.getBody());
}
示例3: getAccessToken
import org.scribe.model.Verifier; //导入依赖的package包/类
@Override
protected String getAccessToken()
{
Verifier verifier = new Verifier(request.getParameter("oauth_verifier"));
Token requestToken = (Token) request.getSession().getAttribute("requestToken");
request.getSession().removeAttribute("requestToken");
OAuthService service = createOAuthScribeService();
Token accessTokenObj = null;
try
{
accessTokenObj = service.getAccessToken(requestToken, verifier);
} catch (OAuthConnectionException e)
{
Organization organizationInstance = organizationService.get(Integer.parseInt(organization), false);
throw new SourceControlException("Error obtaining access token. Cannot access " + organizationInstance.getHostUrl() + " from Jira.", e);
} finally
{
httpClientProvider.closeIdleConnections();
}
return BitbucketOAuthAuthentication.generateAccessTokenString(accessTokenObj);
}
示例4: doFinish
import org.scribe.model.Verifier; //导入依赖的package包/类
public String doFinish()
{
// now get the access token
Verifier verifier = new Verifier(request.getParameter("oauth_verifier"));
Token requestToken = (Token) request.getSession().getAttribute(SESSION_KEY_REQUEST_TOKEN);
if (requestToken == null)
{
log.debug("Request token is NULL. It has been removed in the previous attempt of adding organization. Now we will stop.");
return getRedirect("ConfigureDvcsOrganizations.jspa?atl_token=" + CustomStringUtils.encode(getXsrfToken()));
}
request.getSession().removeAttribute(SESSION_KEY_REQUEST_TOKEN);
OAuthService service = createOAuthScribeService();
Token accessTokenObj = service.getAccessToken(requestToken, verifier);
accessToken = BitbucketOAuthAuthentication.generateAccessTokenString(accessTokenObj);
httpClientProvider.closeIdleConnections();
return doAddOrganization();
}
示例5: getAccessToken
import org.scribe.model.Verifier; //导入依赖的package包/类
@Override
public Token getAccessToken(Token token, Verifier verifier) {
OAuthRequest request =
new OAuthRequest(api.getAccessTokenVerb(), api.getAccessTokenEndpoint());
request.addHeader("Authorization", prepareAuthorizationHeaderValue());
request.addBodyParameter(GRANT_TYPE, GRANT_TYPE_VALUE);
request.addBodyParameter(CODE, verifier.getValue());
Response response = request.send();
if (response.getCode() == SC_OK) {
Token t = api.getAccessTokenExtractor().extract(response.getBody());
return new Token(t.getToken(), config.getApiSecret());
}
throw new OAuthException(
String.format(
"Error response received: %s, HTTP status: %s",
response.getBody(), response.getCode()));
}
示例6: signupViaFacebook
import org.scribe.model.Verifier; //导入依赖的package包/类
@Get("/sign-up/facebook/")
public void signupViaFacebook(String code, String state) {
if (code == null) {
includeAsList("mamuteMessages", i18n("error", "error.signup.facebook.unknown"));
redirectTo(SignupController.class).signupForm();
return;
}
Token token = service.getAccessToken(null, new Verifier(code));
SocialAPI facebookAPI = new FacebookAPI(service, token);
boolean success = loginManager.merge(MethodType.FACEBOOK, facebookAPI);
if(!success) {
includeAsList("mamuteMessages", i18n("error", "signup.errors.facebook.invalid_email", state));
result.redirectTo(AuthController.class).loginForm(state);
return;
}
redirectToRightUrl(state);
}
示例7: getSwiftAccess
import org.scribe.model.Verifier; //导入依赖的package包/类
public static SwiftAccess getSwiftAccess ()
{
final HasAuthenticationSettings authSettings = Configuration.INSTANCE.getAuthenticationSettings() ;
String apiKey = authSettings.getClientId() ;
String apiSecret = authSettings.getClientSecret() ;
HubicOAuth20ServiceImpl service = (HubicOAuth20ServiceImpl) new ServiceBuilder()
.provider(HubicApi.class).apiKey(apiKey).apiSecret(apiSecret)
//.scope("account.r,links.rw,usage.r,credentials.r").callback(HubicApi.CALLBACK_URL)
.scope(scope).callback(HubicApi.CALLBACK_URL)
.build();
Verifier verif = service.obtainVerifier();
if (verif == null)
return null ;
Token accessToken = service.getAccessToken(null, verif);
return getSwiftAccess (service, accessToken) ;
}
示例8: doAuth
import org.scribe.model.Verifier; //导入依赖的package包/类
@Override
protected void doAuth( Intent intent )
{
final String code = intent.getStringExtra( SitesLoginHandler.VERIFIER_KEY );
Token accessToken = null;
String userName = null;
try
{
OAuthService service = new ServiceBuilder()
.provider( InstagramApi.class )
.callback( InstagramLoginActivity.CALLBACK_URL )
.apiKey( InstagramConfig.INSTAGRAM_CLIENT_ID )
.apiSecret( InstagramConfig.INSTAGRAM_CLIENT_SECRET )
.scope( InstagramConfig.INSTAGRAM_SCOPE )
.build();
accessToken = service.getAccessToken( null, new Verifier( code ) );
userName = Helper.extractInstagramUserName( accessToken.getRawResponse() );
}
catch ( Exception e )
{
Helper.debug( "Error while obtaining Instagram access token : " + e.getMessage() );
}
boolean success = null != accessToken;
// Subscriber : InstagramLoginHandler : onInstagramAuthDone()
HashtaggerApp.bus.post( new InstagramAuthDoneEvent( success, accessToken, userName ) );
}
示例9: getAccessToken
import org.scribe.model.Verifier; //导入依赖的package包/类
/**
* Step 4: Get the access Token.
*
* @param verifier Provided by the service and entered by the user
*/
public Token getAccessToken(final String verifier) {
lock.writeLock().lock();
try {
if (state != OAuthState.GET_ACCESS_TOKEN) {
throw new IllegalStateException("Request token not found!");
}
accessToken = service.getAccessToken(requestToken, new Verifier(verifier));
state = OAuthState.READY;
return accessToken;
} finally {
lock.writeLock().unlock();
}
}
示例10: getAccessToken
import org.scribe.model.Verifier; //导入依赖的package包/类
@Override
public Token getAccessToken(Token requestToken, Verifier verifier) {
OAuthRequest request = new OAuthRequest(api.getAccessTokenVerb(), api.getAccessTokenEndpoint());
switch (api.getAccessTokenVerb()) {
case POST:
request.addBodyParameter(OAuthConstants.CLIENT_ID, config.getApiKey());
request.addBodyParameter(OAuthConstants.CLIENT_SECRET, config.getApiSecret());
request.addBodyParameter(OAuthConstants.CODE, verifier.getValue());
request.addBodyParameter(OAuthConstants.REDIRECT_URI, config.getCallback());
request.addBodyParameter(GRANT_TYPE, GRANT_TYPE_AUTHORIZATION_CODE);
break;
case GET:
default:
request.addQuerystringParameter(OAuthConstants.CLIENT_ID, config.getApiKey());
request.addQuerystringParameter(OAuthConstants.CLIENT_SECRET, config.getApiSecret());
request.addQuerystringParameter(OAuthConstants.CODE, verifier.getValue());
request.addQuerystringParameter(OAuthConstants.REDIRECT_URI, config.getCallback());
if(config.hasScope()) request.addQuerystringParameter(OAuthConstants.SCOPE, config.getScope());
}
Response response = request.send();
return api.getAccessTokenExtractor().extract(response.getBody());
}
示例11: getAccessToken
import org.scribe.model.Verifier; //导入依赖的package包/类
/**
* アクセストークン(access Token)を取得
*/
private boolean getAccessToken() {
Log.v(TAG, "getAccessToken called");
if (mAccessToken != null) {
return true;
}
AsyncTask<Void, Void, Boolean> task = new AsyncTask<Void, Void, Boolean>() {
@Override
protected Boolean doInBackground(Void... voids) {
// HTTP通信を行うため、非UIスレッドで実行します。
Verifier verifier = new Verifier(mOAuthPin);
mAccessToken = mService.getAccessToken(mRequestToken, verifier); // the requestToken you had from step 2
return true;
}
@Override
protected void onPostExecute(Boolean aBoolean) {
start();
}
};
task.execute();
return false;
}
示例12: getAccessToken
import org.scribe.model.Verifier; //导入依赖的package包/类
/**
* アクセストークン(access Token)を取得
*/
private boolean getAccessToken() {
Log.v(TAG, "getAccessToken called");
if (mAccessToken != null) {
return true;
}
AsyncTask<Void, Void, Boolean> task = new AsyncTask<Void, Void, Boolean>() {
@Override
protected Boolean doInBackground(Void... voids) {
// HTTP通信を行うため、非UIスレッドで実行します。
Verifier verifier = new Verifier(mOAuthPin);
mAccessToken = mService.getAccessToken(null, verifier);
Log.v(TAG, "mAccessToken=" + mAccessToken);
return true;
}
@Override
protected void onPostExecute(Boolean aBoolean) {
start();
}
};
task.execute();
return false;
}
示例13: getAccessToken
import org.scribe.model.Verifier; //导入依赖的package包/类
/**
* アクセストークン(access Token)を取得
*/
private boolean getAccessToken() {
Log.v(TAG, "getAccessToken called");
if (mAccessToken != null) {
return true;
}
AsyncTask<Void, Void, Boolean> task = new AsyncTask<Void, Void, Boolean>() {
@Override
protected Boolean doInBackground(Void... voids) {
// HTTP通信を行うため、非UIスレッドで実行します。
Verifier verifier = new Verifier(mOAuthVerifier);
mAccessToken = mService.getAccessToken(mRequestToken, verifier); // the requestToken you had from step 2
return true;
}
@Override
protected void onPostExecute(Boolean aBoolean) {
start();
}
};
task.execute();
return false;
}
示例14: getAccessToken
import org.scribe.model.Verifier; //导入依赖的package包/类
/**
* アクセストークン(access Token)を取得
*/
private boolean getAccessToken() {
Log.v(TAG, "getAccessToken called");
if (mAccessToken != null) {
return true;
}
AsyncTask<Void, Void, Boolean> task = new AsyncTask<Void, Void, Boolean>() {
@Override
protected Boolean doInBackground(Void... voids) {
// HTTP通信を行うため、非UIスレッドで実行します。
Verifier verifier = new Verifier(mOAuthVerifier);
mAccessToken = mService.getAccessToken(null, verifier);
Log.v(TAG, "mAccessToken=" + mAccessToken);
return true;
}
@Override
protected void onPostExecute(Boolean aBoolean) {
start();
}
};
task.execute();
return false;
}
示例15: getAccessToken
import org.scribe.model.Verifier; //导入依赖的package包/类
/**
* アクセストークン(access Token)を取得
*/
private boolean getAccessToken() {
if (mAccessToken != null) {
return true;
}
Log.v(TAG, "getAccessToken called");
AsyncTask<Void, Void, Boolean> task = new AsyncTask<Void, Void, Boolean>() {
@Override
protected Boolean doInBackground(Void... voids) {
// HTTP通信を行うため、非UIスレッドで実行します。
Verifier verifier = new Verifier(mOAuthVerifier);
mAccessToken = mService.getAccessToken(null, verifier);
Log.v(TAG, "mAccessToken=" + mAccessToken);
return true;
}
@Override
protected void onPostExecute(Boolean aBoolean) {
start();
}
};
task.execute();
return false;
}