public String generateInviteLink ( String email ) throws OAuthSystemException , OAuthProblemException , URISyntaxException { cleanError ( ) ; prepareToken ( ) ; OneloginURLConnectionClient httpClient = new OneloginURLConnectionClient ( ) ; OAuthClient oAuthClient = new OAuthClient ( httpClient ) ; URIBuilder url = new URIBuilder ( settings . getURL ( Constants . GENERATE_INVITE_LINK_URL ) ) ; OAuthClientRequest bearerRequest = new OAuthBearerClientRequest ( url . toString ( ) ) . buildHeaderMessage ( ) ; Map < String , String > headers = getAuthorizedHeader ( ) ; bearerRequest . setHeaders ( headers ) ; Map < String , Object > params = new HashMap < String , Object > ( ) ; params . put ( "email" , email ) ; String body = JSONUtils . buildJSON ( params ) ; bearerRequest . setBody ( body ) ; String urlLink = null ; OneloginOAuthJSONResourceResponse oAuthResponse = oAuthClient . resource ( bearerRequest , OAuth . HttpMethod . POST , OneloginOAuthJSONResourceResponse . class ) ; if ( oAuthResponse . getResponseCode ( ) == 200 ) { if ( oAuthResponse . getType ( ) . equals ( "success" ) ) { if ( oAuthResponse . getMessage ( ) . equals ( "Success" ) ) { Object [ ] objArray = oAuthResponse . getArrayFromData ( ) ; urlLink = ( String ) objArray [ 0 ] ; } } } else { error = oAuthResponse . getError ( ) ; errorDescription = oAuthResponse . getErrorDescription ( ) ; } return urlLink ; }
Generates an invite link for a user that you have already created in your OneLogin account .