I am new in Docusign.
I have a requirement to create an envelope and show envelope inside Iframe for adding the signature of the user. But I am not getting direct URL by that I user directly sign it.
Currently, the user is getting mail in that user is getting URL. On clicking on that URL, the user is able to sign.
I am using below code to generate URL for Iframe
public ViewUrl getViewUrl(EnvelopeSummary envelopeSummary, Recipients recipients) throws ApiException{
EnvelopesApi envelopesApi = new EnvelopesApi(DocusignFactory.appClient());
RecipientViewRequest returnUrl = new RecipientViewRequest();
returnUrl.setReturnUrl("https://www.docusign.com/devcenter");
returnUrl.setAuthenticationMethod("email");
Signer signer = recipients.getSigners().get(0);
returnUrl.setEmail("myemail#gamil.com");
Tabs tabs = signer.getTabs();
String usename= tabs.getFirstNameTabs().get(0).getName()+" "+tabs.getLastNameTabs().get(0).getName();
returnUrl.setUserName(usename);
return envelopesApi.createRecipientView(DocusignFactory.getDocusignLogin().getAccountId(), envelopeSummary.getEnvelopeId().toString(), returnUrl);}
By using above code I am getting URL. But that URL is just showing the envelope.
Getting Recipients object from EnvelopeTemplate Object and modifying object according to my inputs
public Recipients populateRecipients(Recipients recipients) {
Signer signer = recipients.getSigners().get(0);
signer.setEmail("myemil#gmail.com");
signer.setName("My Name");
//signer.setNote("Here");
signer.setRecipientId("1");
signer.setClientUserId("1001");
signer.setDeliveryMethod("Email");
Tabs tabs = signer.getTabs();
DateSigned dateSigned = tabs.getDateSignedTabs().get(0);
dateSigned.setValue("01/01/2017");
dateSigned.setDocumentId("1");
dateSigned.setRecipientId("1");
//dateSigned.setTabId("1");
List<DateSigned> dateSigneds = new ArrayList<DateSigned>();
dateSigneds.add(dateSigned);
tabs.setDateSignedTabs(dateSigneds);
EmailAddress emailAddress =tabs.getEmailAddressTabs().get(0);
emailAddress.setName("myemil#gmail.com");
emailAddress.setDocumentId("");
emailAddress.setRecipientId("1");
//emailAddress.setTabId("2");
List<EmailAddress> emailAddresss = new ArrayList<EmailAddress>();
emailAddresss.add(emailAddress);
tabs.setEmailAddressTabs(emailAddresss);
FirstName firstName = tabs.getFirstNameTabs().get(0);
firstName.setName("firstName");
firstName.setDocumentId("1");
firstName.setRecipientId("1");
//firstName.setTabId("3");
List<FirstName> firstNames = new ArrayList<FirstName>();
firstNames.add(firstName);
tabs.setFirstNameTabs(firstNames);
LastName lastName = tabs.getLastNameTabs().get(0);
lastName.setName("lastName");
lastName.setDocumentId("1");
lastName.setRecipientId("1");
//lastName.setTabId("4");
List<LastName> lastNames = new ArrayList<LastName>();
lastNames.add(lastName);
tabs.setLastNameTabs(lastNames);
signer.setTabs(tabs);
List<Signer> signers = new ArrayList<Signer>();
signers.add(signer);
recipients.setSigners(signers);
return recipients;
You're missing one of the required parameters for the Recipient View (https://docs.docusign.com/esign/restapi/Envelopes/EnvelopeViews/createRecipient) method --
clientUserId A sender created value that shows [that] the recipient is embedded (captive). Maximum of 100 characters.
Create a value for the clientUserId and include it for the signer when you create the transaction (when you send the signing request).
Then include it when you want the Recipient View. It's a security measure to ensure that it is ok for your web app to authenticate the signer.
Only include the clientUserId for signers where you can authenticate them yourself and you plan to offer them the embedded signing view.
Related
our company has exchange server and there are few users.So i want to list all users in our company and read emails of all users email one by one.How can i do that?
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1); // your server version
ExchangeCredentials credentials = new WebCredentials("user.name#domain.com", "password!"); // change them to your email username, password, email domain
service.setCredentials(credentials);
service.setUrl(new URI("domain/EWS/Exchange.asmx"));
final int pageSize = 50;
ItemView view = new ItemView(pageSize);
FindItemsResults<Item> findResults;
do {
findResults = service.findItems(WellKnownFolderName.Inbox, view);
for (Item item : findResults.getItems()) {
// reading emails
}
view.setOffset(view.getOffset() + pageSize);
} while (findResults.isMoreAvailable());
With the above code i am able to get retrieve email of that particular account whose credentials i have provided in above code.But how can i list users emails id of company and retrieve emails of each user.Please help me with this.
Thanks in advance.
I am trying to access emails on a Office365 mailbox, using Exchange Web Services (EWS).
My O365 admin has created :
the shared mailbox : shared#domain.com
the account : my.account#domain.com
a group, giving access to the account on the mailbox
I am able to retrieve the Oauth token using the appId/tenantId and a UserNamePasswordParameters using the account's credentials, and now I am trying to retrieve the emails from the mailbox, but I get this error :
microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException:
Mailbox does not exist.
here's my code :
public Iterable fetchEmails(String token, String account) throws Exception {
if(token==null) {
token = getToken();
}
FindItemsResults<Item> emails;
try (ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2)) {
service.getHttpHeaders().put("Authorization", "Bearer " + token);
service.setUrl(new URI("https://outlook.office365.com/EWS/Exchange.asmx"));
service.setWebProxy(new WebProxy(PROXY_HOST, PROXY_PORT));
FolderId folder = new FolderId(WellKnownFolderName.Inbox, new Mailbox(account));
emails = service.findItems(folder, new ItemView(15));
}
return emails;
}
OK, it was a bit stupid.. I got confused because the account is also an email..
solution is to pass the mailbox (shared#domain.com) instead of the account (my.account#domain.com) when building the Mailbox object :
FolderId folder = new FolderId(WellKnownFolderName.Inbox, new Mailbox("shared#domain.com"));
And now it's working, I am able to get the emails.
I have recently started playing with the Bing Ads api for managing my ads and campaigns and I am having problem in authenticating user (not oauth authentication).
I authenticated my user using oauth by the following
private String devToken = "ZZZZZ";
private String clientId = "AAA0BBB-XXXX-AAAAA";
protected static String UserName = "a.v#h.c";
protected static String Password = "********";
// To get the initial access and refresh tokens you must call requestAccessAndRefreshTokens with the authorization redirection URL.
OAuthTokens tokens = oAuthDesktopMobileAuthCodeGrant.requestAccessAndRefreshTokens(url);
System.out.println("Access token: " + tokens.getAccessToken());
System.out.println("Refresh token: " + tokens.getRefreshToken());
authorizationData = new AuthorizationData();
authorizationData.setDeveloperToken(getDevToken());
authorizationData.setAuthentication(oAuthDesktopMobileAuthCodeGrant);
This authenticates my user just fine since I can use the ICustomerManagementService.class just fine for accounts related information
customerServiceClient = new ServiceClient<>(authorizationData, ICustomerManagementService.class);
ArrayOfAccount accounts = searchAccountsByUserId(user.getId());
The above works perfectly. But when I try to do the same with ICampaignManagementService.class like below
campaignServiceClient = new ServiceClient<>(authorizationData, ICampaignManagementService.class);
GetAdsByAdGroupIdRequest cReq = new GetAdsByAdGroupIdRequest();
cReq.setAdGroupId(1234567890L);
campaignServiceClient.getService().getAdsByAdGroupId(cReq);
I get error code 106 saying that the user is not authorized.
The user does not represent a authorized developer.
106
Any help in this regard ?
Please try to set the CustomerId and CustomerAccountId header elements (CustomerId and AccountId of AuthorizationData). These headers are not available with the Customer Management service, but are applicable for Campaign Management service. If that does not resolve the issue please feel free to send the SOAP request + response to support for investigation. I hope this helps!
I have an app that already has a login system and user objects, etc. I want to adapt it so it can authenticate using a SAML identity provider.
To do so I need to construct a page that sends the user to the identity provider to login. Here is what I've come up with so far to test with:
public String getSamlLoginPage() throws IOException, ConfigurationException {
DefaultBootstrap.bootstrap();
AuthnRequest authnRequest = buildSamlObject(AuthnRequest.DEFAULT_ELEMENT_NAME,AuthnRequestBuilder.class);
String myResponseUrl = "http://localhost:8080/samltest/saml?action=samlLogin";
String serviceProviderEntityId = "someProviderEntityId";
// set information in request
{
authnRequest.setForceAuthn(false);
authnRequest.setIsPassive(false);
authnRequest.setIssueInstant(new DateTime());
authnRequest.setDestination(myResponseUrl);
authnRequest.setProtocolBinding(SAMLConstants.SAML2_ARTIFACT_BINDING_URI);
authnRequest.setAssertionConsumerServiceURL(myResponseUrl);
authnRequest.setID(""+UUID.randomUUID().getLeastSignificantBits());
Issuer issuer = buildSamlObject(Issuer.DEFAULT_ELEMENT_NAME, IssuerBuilder.class);
issuer.setValue(serviceProviderEntityId);
authnRequest.setIssuer(issuer);
NameIDPolicy nameIDPolicy = buildSamlObject(NameIDPolicy.DEFAULT_ELEMENT_NAME, NameIDPolicyBuilder.class);
nameIDPolicy.setSPNameQualifier(serviceProviderEntityId);
nameIDPolicy.setAllowCreate(true);
nameIDPolicy.setFormat("urn:oasis:names:tc:SAML:2.0:nameid-format:transient");
authnRequest.setNameIDPolicy(nameIDPolicy);
RequestedAuthnContext requestedAuthnContext = buildSamlObject(RequestedAuthnContext.DEFAULT_ELEMENT_NAME,RequestedAuthnContextBuilder.class);
requestedAuthnContext.setComparison(AuthnContextComparisonTypeEnumeration.MINIMUM);
AuthnContextClassRef authnContextClassRef = buildSamlObject(AuthnContextClassRef.DEFAULT_ELEMENT_NAME,AuthnContextClassRefBuilder.class);
authnContextClassRef.setAuthnContextClassRef("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport");
requestedAuthnContext.getAuthnContextClassRefs().add(authnContextClassRef);
authnRequest.setRequestedAuthnContext(requestedAuthnContext);
}
String samlRequestStr = XMLUtil.doc2String( authnRequest.getDOM() );
byte[] samlRequest = samlRequestStr.getBytes(); // <samlp:AuthnRequest>
ByteArrayOutputStream bout = new ByteArrayOutputStream(500);
Base64.encode(samlRequest,bout);
return
"<html><body>"
+"<form method=\"post\" action=\"https://idp.example.org/SAML2/SSO/POST\">"
+" <input type=\"hidden\" name=\"SAMLRequest\" value=\""+ bout.toString() +"\" />"
// +" <input type=\"hidden\" name=\"RelayState\" value=\"someToken\" />"
+" <input type=\"submit\" value=\"Submit\" />"
+" </form>"
+"<body></html>";
}
private <SAMLObjectType extends SAMLObject, BuilderT extends SAMLObjectBuilder<SAMLObjectType>> SAMLObjectType buildSamlObject(javax.xml.namespace.QName defaultElementName, Class<BuilderT> type) {
XMLObjectBuilderFactory builderFactory = org.opensaml.Configuration.getBuilderFactory();
BuilderT requestBuilder = (BuilderT)builderFactory.getBuilder(defaultElementName);
return requestBuilder.buildObject();
}
I'll need to change the action to point to the actual identity provider. Beyond that, what am I supposed to put into the Request object? All I need is for the identity provider to verify that the user is a real user (they'll login with email and password at the identity provider) and then communicate to me what their email address is along with some sort of signature that I can validate to prove that the user has been validated by the identity provider.
All other information about the user is stored locally, so email and idp signature is all I need.
The saml request has to contain a couple of things. It usually also have to be signed. Here is a blog post I have written on how to create a Authn SAML request using OpenSAML
I also have a book, A Guide to OpenSAML, that gives a good introduction to SAML and the OpenSAML library.
Hi I am writing a connector tool using GAE Java which adds,updates, deletes and
retrieves calendar events.I am using 2 legged authentication for the same. I am able to add new events successfully using 2 legged authentication but not able to
update, delete or retrieve events using the same.
It gives following error while I try to do either of update/delete/retrieve operation on calendar event.
com.google.gdata.util.AuthenticationException: OK
<HTML>
<HEAD>
<TITLE>Token invalid - Invalid AuthSub token.</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Token invalid - Invalid AuthSub token.</H1>
<H2>Error 401</H2>
</BODY>
</HTML>
The same code works fine if I remove OAuth specific code and just use service.setUserCredentials() method.
Kindly help me out to resolve this issue. Please revert back in case
more information on this is required.
Thanks in advance.
-Nirzari
Below is the code snippet
//Code for getCalendarEvents
String url = FEED_URL + "?xoauth_requestor_id="
+ "u...#domain.com";
URL postUrl = new URL(url);
GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();
oauthParameters.setScope(Scope);
oauthParameters.setOAuthConsumerKey(ConsumerKey);
oauthParameters.setOAuthConsumerSecret(secret);
CalendarService myService = new CalendarService("getAppointments");
OAuthSigner signer = new OAuthHmacSha1Signer();
myService.setOAuthCredentials(oauthParameters, signer);
CalendarQuery myQuery = new CalendarQuery(postUrl);
CustomParameter customParameter = new CustomParameter("showdeleted",
"true");
myQuery.addCustomParameter(customParameter);
CalendarEventFeed resultFeed = myService.query(myQuery,
CalendarEventFeed.class);
//Code for Update Appointment
String url = FEED_URL + "?xoauth_requestor_id=" +
"usern...#domain.com";
URL postUrl = new URL(url);
GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();
oauthParameters.setScope(Scope);
oauthParameters.setOAuthConsumerKey(ConsumerKey);
oauthParameters.setOAuthConsumerSecret(secret);
CalendarService myService = new CalendarService("updateAppointment");
OAuthSigner signer = new OAuthHmacSha1Signer();
myService.setOAuthCredentials(oauthParameters, signer);
CalendarQuery myQuery = new CalendarQuery(postUrl);
myQuery.setExtendedPropertyQuery(new ExtendedPropertyMatch(
"Prop_Name", value));
CalendarEventFeed resultFeed = myService.getFeed(myQuery,
CalendarEventFeed.class);
if (resultFeed != null && resultFeed.getEntries().size() > 0) {
CalendarEventEntry matchEntry = (CalendarEventEntry) resultFeed
.getEntries().get(0);
updateCalendarEntry(matchEntry, description, title, start, end, startTime, endTime, location, priavte, guestList);
matchEntry.update();
One of the possible causes could be that user email is not URL encoded (# should be encoded as %40). Use this code, that handles URL encoding automatically:
query.addCustomParameter(new CustomParameter("xoauth_requestor_id", userEmail));
rather than append parameter manually.
Another possible cause is that your app doesn't have granted access to Calendar by administrator of Google Apps domain, to which the user belongs. You can check it on this page: https://www.google.com/a/cpanel/DOMAIN-NAME/ManageOauthClients.