public interface ApplicationLinkRequestFactory extends AuthorisationURIGenerator
ApplicationLinkRequest objects. Use the
ReadOnlyApplicationLink.createAuthenticatedRequestFactory() or
ReadOnlyApplicationLink.createAuthenticatedRequestFactory(Class) method to create an
ApplicationLinkRequestFactory targeting a particular remote ApplicationLink.| Modifier and Type | Method and Description |
|---|---|
ApplicationLinkRequest |
createRequest(com.atlassian.sal.api.net.Request.MethodType methodType,
String url)
Creates a request of the given method type to the given url.
|
getAuthorisationURI, getAuthorisationURIApplicationLinkRequest createRequest(com.atlassian.sal.api.net.Request.MethodType methodType, String url) throws CredentialsRequiredException
AuthenticationProviders. See
ReadOnlyApplicationLink.createAuthenticatedRequestFactory() for more details.
ApplicationLinkRequestFactoryrequestFactory =ReadOnlyApplicationLink.createAuthenticatedRequestFactory();ApplicationLinkRequestrequest; try { request = requestFactory.createRequest(Request.MethodType#GET, "/rest/my-plugin/1.0/my-resource"); } catch (CredentialsRequiredExceptione) { // we don't have credentials stored for the context user, so prompt user to authenticate // using the URI provided byCredentialsRequiredException.getAuthorisationURI()// ... } try { boolean success = request.execute(newApplicationLinkResponseHandler<Boolean>() { Boolean handle(Responseresponse) throwsResponseException{ return response.Response.isSuccessful()) } Boolean credentialsRequired(Responseresponse) throwsResponseException{ // the remote server rejected our credentials, so prompt the user to authenticate // using the URI provided byAuthorisationURIGenerator.getAuthorisationURI()// ... } }); } catch (ResponseExceptionre) { // the request failed to complete normally }
methodType - The HTTP method typeurl - The target of the request. If you specify a URI that does not start with a protocol string
(e.g. http: or https:) the target ApplicationLink's rpcUrl will be pre-pended to the request
URI. Specified absolute URIs will be used as is.ApplicationLinkRequest objectCredentialsRequiredException - when the target ApplicationLink requires authentication, but no
credentials are available for the context user.CredentialsRequiredExceptionCopyright © 2020 Atlassian. All rights reserved.