How to get oauth AccessToken in classic asp - oauth-2.0

I want to send email by connecting google via oauth
Below is the code present for C#
MailSender objMail = new MailSender();
objMail.TLS = true;
objMail.Username = "myaccount#gmail.com";
objMail.Password = "[oauth]ya29.Il-8B-88nf.......GhoNhUXKtBS-ZEQOAZ9tTWg";
...
objMail.Send();
For whole code please navigate to
https://www.aspemail.com/net_manual_03.html#3_5
To generate access token which is appended with "[oauth]" above, we are using
MailSender objMail = new MailSender();
MailSender objMail2 = objMail.GetAccessToken("GMAIL", "4/wQGBh....LtcM", false);
string AccessToken = objMail2.Username;
string RefreshToken = objMail2.Password;
int ExpiresIn = objMail2.Timeout;
I want to implement the same functionality in classic asp, but when i am creating object of "MailSender" in classic asp, it is throwing error that:
Object doesn't support this property or method:
'objMail.GetAccessToken'
Please suggest me how can i generate access token of oauth from classic asp

That error is telling you that the object you are using doesn’t recognise the method you are trying to call. In this situation the official documentation is the best resource.
Quote from GetAccessToken()
This method was introduced in version 5.5.0.1.
The likelihood here is you are using an older version of the ASPEmail COM component.
You can use the below code to output the version information;
<%
Dim Mail
Set Mail = Server.CreateObject("Persits.MailSender")
Call Response.Write("Version: " & Mail.Version)
%>

Related

Is there a way to parse xml in docusign?

Is there a way to parse xml in docusign? And if so, how does this work? I do not find any user guide or something like this.
Thank you for your support
I would recommend that you use the REST API. the SOAP API is very old and not actively being worked on.
To retrieve values from a DocuSign "form" (we call it an envelope) you can use the following code example:
Here is a C# snippet, you get back at the end JSON with all the form data.
// Step 1: Obtain your OAuth token
var accessToken = RequestItemsService.User.AccessToken; // Represents your {ACCESS_TOKEN}
var accountId = RequestItemsService.Session.AccountId; // Represents your {ACCOUNT_ID}
var envelopeId = RequestItemsService.EnvelopeId;
// Step 2: Construct your API headers
var config = new Configuration(new ApiClient(basePath));
config.AddDefaultHeader("Authorization", "Bearer " + accessToken);
// Step 3: Call the eSignature REST API
EnvelopesApi envelopesApi = new EnvelopesApi(config);
EnvelopeFormData results = envelopesApi.GetFormData(accountId, envelopeId);

OAuth2 authentication error using 'python-o365' library

I have able to successfully connect and read emails using the 'python-o365' library:
Connection.oauth2('Client_ID','Client_Secret',store_token=True)
inbox = FluentInbox()
for message in inbox.fetch_next(2):
print(message.getSubject())
However, when I try to send an email using a more basic example, I am receiving a 401 response from the server.
Connection.oauth2('Client_ID','Client_Secret',store_token=True)
att = Attachment(path=FilePath)
m = Message()
m.setRecipients(EmailTo)
m.setSubject('DBM Errors Identified - ' + FileName)
m.setBody(MessageBody)
m.attachments.append(att)
m.sendMessage()
I have also tried setting the connection object and passing it through as a parameter:
auth = Connection.oauth2('Client_ID','Client_Secret',store_token=True)
m = Message(*auth=auth*)
That however results in an error message of:
TypeError: 'Connection' object is not callable
Thanks for the help!
I was able to bypass the issue by switching to a fork of the 'python-o365' library that I used above. I feel like I am probably missing something obvious with that library but this solved the problem
Here is the simplified version of the authentication flow that I have working in case it interests anyone:
scopes = ['https://graph.microsoft.com/Mail.Read'']
account = Account(('Client_Id', 'Client_Secret'], auth_method='oauth',scopes=scopes)
account.connection.get_authroization_url() #generate the url for user to authenticate
result_url = input('Paste the result URL once you have authenticated...')
account.connection.get_session() #generate a session
m = account.new_message()
m.to.add('EmailTo')
m.body = 'MessageText'
m.send()

How to set callback URL for Google OAuth?

I am using Google OAuth to authenticate the user in my GAE application. After the user clicks on "Grant Access", I want to return to my application. I tried setting the callback URL, but instead of being called independently, it gets appended to the current URL in the browser, and thus shows as an invalid URL.
Here is my code:
OAuthGetTemporaryToken requestToken = new OAuthGetTemporaryToken(REQUEST_TOKEN_URL);
requestToken.consumerKey = CONSUMER_KEY;
requestToken.transport = TRANSPORT;
requestToken.signer = signer;
requestToken.callback="www.mail.yahoo.com";
OAuthCredentialsResponse requestTokenResponse = requestToken.execute();
// updates signer's token shared secret
signer.tokenSharedSecret = requestTokenResponse.tokenSecret;
OAuthAuthorizeTemporaryTokenUrl authorizeUrl = new OAuthAuthorizeTemporaryTokenUrl(AUTHORIZE_URL);
authorizeUrl.temporaryToken = requestTokenResponse.token;
This line sends it to the Google OAuth page.
resp.sendRedirect(authorizeUrl.build());
I have set the callback parameter as shown above, but it's not working. Please help! Thanks in advance.
This is OAuth1 stuff, which is deprecated. Try using OAuth 2.0 instead. Start at https://developers.google.com/accounts/docs/OAuth2

LinkedIn RestSharp and OAuthBase Example

anyone ever used C# in combination with the library RestSharp and OAuthBase in order get some interaction with LinkedIn?
I'm looking for a working example using these tools to do proper authorization (oAuth 2.0) and to publish a post using the share API on LinkedIn.
So far I've been successful using these tools to obtain valid access tokens (I can use it to obtain profile information for example), but posting via the share API got me stuck on authentication.
Any help would be very much appreciated!!
it turned out to be much simpler than I was thinking.... (doesn't it allways?)
The main point to take into account is: oAuth 2.0 does not require signatures, nonce, timestamps, authorization headers ... none of that.
If you want to post on LinkedIn using the sahres API and using oAuth2.0 ... OAuthbase is not needed.
Simply follow the oauth 2.0 authentication flow as described here:
http://developer.linkedin.com/documents/authentication
And then you can use the following code as a starting point:
var shareMsg = new
{
comment = "Testing out the LinkedIn Share API with JSON",
content = new
{
title = "Test post to LinkedIn",
submitted_url = "http://www.somewebsite.com",
submitted_image_url = "http://www.somewebsite.com/image.png"
},
visibility = new
{
code = "anyone"
}
};
String requestUrl = "https://api.linkedin.com/v1/people/~/shares?oauth2_access_token=" + accessToken;
RestClient rc = new RestClient();
RestRequest request = new RestRequest(requestUrl, Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("x-li-format", "json");
request.RequestFormat = DataFormat.Json;
request.AddBody(shareMsg);
RestResponse restResponse = (RestResponse)rc.Execute(request);
ResponseStatus responseStatus = restResponse.ResponseStatus;
Happy coding!!

How to remove an attachment using JIRA soap service

Reading the API I don't see any methods that can do this?
http://docs.atlassian.com/software/jira/docs/api/rpc-jira-plugin/latest/index.html?com/atlassian/jira/rpc/soap/JiraSoapService.html
Yes, it would need a custom SOAP plugin. Not too hard, just annoying that the method isn't there.
~Matt
SOAP doesn't support this, but you can do it via HTTP, e.g. (C#)
using (System.Net.WebClient client = new System.Net.WebClient())
{
string url = "http://jira-server/secure/DeleteAttachment.jspa?id=" +
issue.id + "&deleteAttachmentId=" + attachment_id;
client.Credentials = System.Net.CredentialCache.DefaultCredentials;
string response = client.DownloadString(url);
// do whatever validation/reporting with the response...
}
You can check the url from your web browser - has to be the deletion confirmation page, not the link from the initial delete button.

Resources