本文整理汇总了Java中com.github.scribejava.core.exceptions.OAuthException类的典型用法代码示例。如果您正苦于以下问题:Java OAuthException类的具体用法?Java OAuthException怎么用?Java OAuthException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OAuthException类属于com.github.scribejava.core.exceptions包,在下文中一共展示了OAuthException类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: sendRequest
import com.github.scribejava.core.exceptions.OAuthException; //导入依赖的package包/类
@Override
protected RequestHandle sendRequest(
cz.msebera.android.httpclient.impl.client.DefaultHttpClient client,
cz.msebera.android.httpclient.protocol.HttpContext httpContext,
cz.msebera.android.httpclient.client.methods.HttpUriRequest uriRequest,
String contentType, ResponseHandlerInterface responseHandler,
Context context) {
if (this.service != null && accessToken != null) {
try {
ScribeRequestAdapter adapter = new ScribeRequestAdapter(uriRequest);
this.service.signRequest(accessToken, adapter);
return super.sendRequest(client, httpContext, uriRequest, contentType, responseHandler, context);
} catch (Exception e) {
e.printStackTrace();
}
} else if (accessToken == null) {
throw new OAuthException("Cannot send unauthenticated requests for " + apiInstance.getClass().getSimpleName() + " client. Please attach an access token!");
} else { // service is null
throw new OAuthException("Cannot send unauthenticated requests for undefined service. Please specify a valid api service!");
}
return null; // Hopefully never reaches here
}
开发者ID:codepath,项目名称:android-oauth-handler,代码行数:24,代码来源:OAuthAsyncHttpClient.java
示例2: create
import com.github.scribejava.core.exceptions.OAuthException; //导入依赖的package包/类
@Override
public CompletableFuture<U> create(final C credentials, final AsyncWebContext context) {
try {
final CompletableFuture<T> tokenFuture = new CompletableFuture<>();
try {
tokenFuture.complete(getAccessToken(credentials));
} catch (HttpAction action) {
tokenFuture.completeExceptionally(action);
}
return tokenFuture.thenCompose(this::retrieveUserProfileFromToken);
} catch (final OAuthException e) {
throw new TechnicalException(e);
}
}
开发者ID:millross,项目名称:pac4j-async,代码行数:15,代码来源:AsyncOAuthProfileCreator.java
示例3: getProfileUrl
import com.github.scribejava.core.exceptions.OAuthException; //导入依赖的package包/类
@Override
protected String getProfileUrl(final OAuth2AccessToken accessToken) {
if (accessToken instanceof OrcidToken) {
return String.format("https://api.orcid.org/v1.1/%s/orcid-profile",
((OrcidToken) accessToken).getOrcid());
} else {
throw new OAuthException("Token in getProfileUrl is not an OrcidToken");
}
}
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:10,代码来源:OrcidClient.java
示例4: retrieveRedirectAction
import com.github.scribejava.core.exceptions.OAuthException; //导入依赖的package包/类
@Override
protected RedirectAction retrieveRedirectAction(final WebContext context) throws HttpAction {
try {
return RedirectAction.redirect(retrieveAuthorizationUrl(context));
} catch (final OAuthException e) {
throw new TechnicalException(e);
}
}
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:9,代码来源:BaseOAuthClient.java
示例5: retrieveCredentials
import com.github.scribejava.core.exceptions.OAuthException; //导入依赖的package包/类
@Override
protected OAuthCredentials retrieveCredentials(final WebContext context) throws HttpAction {
// check if the authentication has been cancelled
if (hasBeenCancelled(context)) {
logger.debug("authentication has been cancelled by user");
return null;
}
// check errors
try {
boolean errorFound = false;
final OAuthCredentialsException oauthCredentialsException = new OAuthCredentialsException("Failed to retrieve OAuth credentials, error parameters found");
for (final String key : OAuthCredentialsException.ERROR_NAMES) {
final String value = context.getRequestParameter(key);
if (value != null) {
errorFound = true;
oauthCredentialsException.setErrorMessage(key, value);
}
}
if (errorFound) {
throw oauthCredentialsException;
} else {
return getOAuthCredentials(context);
}
} catch (final OAuthException e) {
throw new TechnicalException(e);
}
}
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:28,代码来源:BaseOAuthClient.java
示例6: retrieveUserProfile
import com.github.scribejava.core.exceptions.OAuthException; //导入依赖的package包/类
@Override
protected U retrieveUserProfile(final OAuthCredentials credentials, final WebContext context) throws HttpAction {
try {
final T token = getAccessToken(credentials);
return retrieveUserProfileFromToken(token);
} catch (final OAuthException e) {
throw new TechnicalException(e);
}
}
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:10,代码来源:BaseOAuthClient.java
示例7: extractParameter
import com.github.scribejava.core.exceptions.OAuthException; //导入依赖的package包/类
public static String extractParameter(String response, String regex) throws OAuthException {
final Matcher matcher = Pattern.compile(regex).matcher(response);
if (matcher.find()) {
return OAuthEncoder.decode(matcher.group(1));
} else {
return null;
}
}
开发者ID:perrywang,项目名称:OAuthGateway,代码行数:9,代码来源:RegexUtil.java
示例8: verifyCharacterStatus
import com.github.scribejava.core.exceptions.OAuthException; //导入依赖的package包/类
private CrestCharacterStatus verifyCharacterStatus() throws IOException {
try {
return verifyCharacterStatus(true);
}
catch (OAuthException e) {
throw new IOException(e);
}
}
开发者ID:evanova,项目名称:eve-crest-java,代码行数:9,代码来源:CrestRetrofit.java
示例9: fromAuthCode
import com.github.scribejava.core.exceptions.OAuthException; //导入依赖的package包/类
public CrestToken fromAuthCode(final String authCode) {
try {
final OAuth2AccessToken token = this.oAuth.getAccessToken(authCode);
return save(token);
}
catch (OAuthException | IOException e) {
LOG.error(e.getMessage(), e);
return null;
}
}
开发者ID:evanova,项目名称:eve-crest-java,代码行数:11,代码来源:CrestClient.java
示例10: fromRefresh
import com.github.scribejava.core.exceptions.OAuthException; //导入依赖的package包/类
public CrestToken fromRefresh(final String refresh) {
try {
CrestToken existing = this.store.get(refresh);
if ((null == existing) || (existing.getExpiresOn() < (System.currentTimeMillis() - 5 * 1000))) {
final OAuth2AccessToken token = this.oAuth.refreshAccessToken(refresh);
return save(token);
}
return existing;
}
catch (OAuthException | IOException e) {
LOG.error(e.getMessage(), e);
return null;
}
}
开发者ID:evanova,项目名称:eve-crest-java,代码行数:15,代码来源:CrestClient.java
注:本文中的com.github.scribejava.core.exceptions.OAuthException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论