本文整理汇总了Java中com.box.boxjavalibv2.requests.requestobjects.BoxOAuthRequestObject类的典型用法代码示例。如果您正苦于以下问题:Java BoxOAuthRequestObject类的具体用法?Java BoxOAuthRequestObject怎么用?Java BoxOAuthRequestObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BoxOAuthRequestObject类属于com.box.boxjavalibv2.requests.requestobjects包,在下文中一共展示了BoxOAuthRequestObject类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doRefresh
import com.box.boxjavalibv2.requests.requestobjects.BoxOAuthRequestObject; //导入依赖的package包/类
/**
* Refresh the OAuth.
*
* @throws BoxRestException
* exception
* @throws BoxServerException
* exception
* @throws AuthFatalFailureException
* exception
*/
private void doRefresh() throws AuthFatalFailureException {
setTokenState(OAuthTokenState.REFRESHING);
try {
mOAuthToken = mClient.getOAuthManager().refreshOAuth(
(BoxOAuthRequestObject) BoxOAuthRequestObject.refreshOAuthRequestObject(mOAuthToken.getRefreshToken(), mClientId, mClientSecret)
.addQueryParam("device_id", mDeviceId).addQueryParam("device_name", mDeviceName));
setTokenState(OAuthTokenState.AVAILABLE);
if (refreshListener != null) {
refreshListener.onRefresh(mOAuthToken);
}
unlock();
}
catch (Exception e) {
setTokenState(OAuthTokenState.FAIL);
throw new AuthFatalFailureException(true);
}
}
示例2: startCreateOAuth
import com.box.boxjavalibv2.requests.requestobjects.BoxOAuthRequestObject; //导入依赖的package包/类
private void startCreateOAuth(final String code) {
if (oauthCreated.getAndSet(true)) {
return;
}
Thread t = new Thread() {
@Override
public void run() {
BoxOAuthToken oauth = null;
try {
oauth = client.getOAuthManager().createOAuth(
BoxOAuthRequestObject.createOAuthRequestObject(code, mWebViewData.getClientId(), mWebViewData.getClientSecret(),
mWebViewData.getRedirectUrl()));
exitSuccess(oauth);
}
catch (Exception e) {
exitException(e);
}
}
};
t.start();
}
示例3: createBoxClient
import com.box.boxjavalibv2.requests.requestobjects.BoxOAuthRequestObject; //导入依赖的package包/类
private static BoxClient createBoxClient(final String code, final String clientId, final String secret) throws BoxRestException, BoxServerException, AuthFatalFailureException {
final BoxResourceHub hub = new BoxResourceHub();
final BoxJSONParser parser = new BoxJSONParser(hub);
final BoxClient client = new BoxClient(clientId, secret, hub, parser);
final BoxOAuthRequestObject oAuthRequestObject = BoxOAuthRequestObject.createOAuthRequestObject(code, clientId, secret, null);
final BoxOAuthToken bt = client.getOAuthManager().createOAuth(oAuthRequestObject);
client.authenticate(bt);
return client;
}
示例4: testRevokeRequestObject
import com.box.boxjavalibv2.requests.requestobjects.BoxOAuthRequestObject; //导入依赖的package包/类
@Test
public void testRevokeRequestObject() throws BoxRestException {
String token = "testtoken1212";
BoxOAuthRequestObject obj = BoxOAuthRequestObject.revokeOAuthRequestObject(token, CLIENT_ID, CLIENT_SECRET);
MapJSONStringEntity jEntity = obj.getJSONEntity();
Assert.assertEquals(CLIENT_ID, jEntity.get("client_id"));
Assert.assertEquals(CLIENT_SECRET, jEntity.get("client_secret"));
Assert.assertEquals(token, jEntity.get("token"));
}
示例5: testCreateRequestObject
import com.box.boxjavalibv2.requests.requestobjects.BoxOAuthRequestObject; //导入依赖的package包/类
@Test
public void testCreateRequestObject() throws BoxRestException {
String code = "testcode";
String url = "testurl";
BoxOAuthRequestObject obj = BoxOAuthRequestObject.createOAuthRequestObject(code, CLIENT_ID, CLIENT_SECRET, url);
MapJSONStringEntity jEntity = obj.getJSONEntity();
Assert.assertEquals(CLIENT_ID, jEntity.get("client_id"));
Assert.assertEquals(CLIENT_SECRET, jEntity.get("client_secret"));
Assert.assertEquals(code, jEntity.get("code"));
Assert.assertEquals(url, jEntity.get("redirect_url"));
}
示例6: testRefreshRequestObject
import com.box.boxjavalibv2.requests.requestobjects.BoxOAuthRequestObject; //导入依赖的package包/类
@Test
public void testRefreshRequestObject() throws BoxRestException {
String token = "testrefreshtoken";
BoxOAuthRequestObject obj = BoxOAuthRequestObject.refreshOAuthRequestObject(token, CLIENT_ID, CLIENT_SECRET);
MapJSONStringEntity jEntity = obj.getJSONEntity();
Assert.assertEquals(CLIENT_ID, jEntity.get("client_id"));
Assert.assertEquals(CLIENT_SECRET, jEntity.get("client_secret"));
Assert.assertEquals(token, jEntity.get("refresh_token"));
}
示例7: refreshOAuth
import com.box.boxjavalibv2.requests.requestobjects.BoxOAuthRequestObject; //导入依赖的package包/类
@Override
public BoxOAuthToken refreshOAuth(final BoxOAuthRequestObject requestObject) throws BoxRestException, BoxServerException, AuthFatalFailureException {
if (refreshShouldFail) {
throw new AuthFatalFailureException();
}
// Let's say refreshing a token takes 1 second.
try {
Thread.sleep(1000);
}
catch (InterruptedException e) {
e.printStackTrace();
}
return createMockToken(MockRestClient.accessToken);
}
示例8: revokeOAuth
import com.box.boxjavalibv2.requests.requestobjects.BoxOAuthRequestObject; //导入依赖的package包/类
public void revokeOAuth(final BoxOAuthRequestObject requestObject) throws BoxServerException, BoxRestException, AuthFatalFailureException {
RevokeOAuthRequest request = new RevokeOAuthRequest(getConfig(), getObjectMapper(), requestObject);
executeRequestWithNoResponseBody(request);
}
示例9: RevokeOAuthRequest
import com.box.boxjavalibv2.requests.requestobjects.BoxOAuthRequestObject; //导入依赖的package包/类
public RevokeOAuthRequest(IBoxConfig config, ObjectMapper objectMapper, BoxOAuthRequestObject requestObject) throws BoxRestException {
super(config, objectMapper, getUri(), RestMethod.POST, requestObject);
}
示例10: createOAuth
import com.box.boxjavalibv2.requests.requestobjects.BoxOAuthRequestObject; //导入依赖的package包/类
@Override
public BoxOAuthToken createOAuth(BoxOAuthRequestObject requestObject) throws BoxRestException, BoxServerException, AuthFatalFailureException {
return createMockToken(MockRestClient.accessToken);
}
示例11: createOAuth
import com.box.boxjavalibv2.requests.requestobjects.BoxOAuthRequestObject; //导入依赖的package包/类
/**
* Create an OAuth token.
*
* @param requestObject
* request object
* @return OAuth data object
* @throws BoxRestException
* exception
* @throws BoxServerException
* exception
* @throws AuthFatalFailureException
* exception
*/
public BoxOAuthToken createOAuth(BoxOAuthRequestObject requestObject) throws BoxRestException, BoxServerException, AuthFatalFailureException {
CreateOAuthRequest request = new CreateOAuthRequest(getConfig(), getObjectMapper(), requestObject);
return (BoxOAuthToken) getResponseAndParseAndTryCast(request, BoxResourceType.OAUTH_DATA, getObjectMapper());
}
示例12: refreshOAuth
import com.box.boxjavalibv2.requests.requestobjects.BoxOAuthRequestObject; //导入依赖的package包/类
/**
* Refresh the OAuth token.
*
* @param requestObject
* request object
* @return OAuth data object
* @throws BoxRestException
* exception
* @throws BoxServerException
* exception
* @throws AuthFatalFailureException
* exception
*/
public BoxOAuthToken refreshOAuth(final BoxOAuthRequestObject requestObject) throws BoxRestException, BoxServerException, AuthFatalFailureException {
RefreshOAuthRequest request = new RefreshOAuthRequest(getConfig(), getObjectMapper(), requestObject);
return (BoxOAuthToken) getResponseAndParseAndTryCast(request, BoxResourceType.OAUTH_DATA, getObjectMapper());
}
示例13: CreateOAuthRequest
import com.box.boxjavalibv2.requests.requestobjects.BoxOAuthRequestObject; //导入依赖的package包/类
/**
* Constructor.
*
* @param config
* config
* @param objectMapper
* object mapper
* @param requestObject
* request object
* @throws BoxRestException
* except
*/
public CreateOAuthRequest(final IBoxConfig config, final ObjectMapper objectMapper, BoxOAuthRequestObject requestObject) throws BoxRestException {
super(config, objectMapper, getUri(), RestMethod.POST, requestObject);
}
示例14: RefreshOAuthRequest
import com.box.boxjavalibv2.requests.requestobjects.BoxOAuthRequestObject; //导入依赖的package包/类
/**
* Constructor.
*
* @param config
* config
* @param objectMapper
* object mapper
* @param requestObject
* request object
* @throws BoxRestException
* exception
*/
public RefreshOAuthRequest(final IBoxConfig config, final ObjectMapper objectMapper, final BoxOAuthRequestObject requestObject) throws BoxRestException {
super(config, objectMapper, getUri(), RestMethod.POST, requestObject);
}