Two Factor Authentication

More
3 years 2 weeks ago - 1 year 6 months ago #247 by Bruce Armstrong
Bruce Armstrong created the code: Two Factor Authentication
Sample code showing how to do two factor authentication using PowerBuilder

This message has an attachment file.
Please log in or register to see it.

Last Edit: 1 year 6 months ago by Bruce Armstrong. Reason: Updating code to work with PowerServer and correct timestamp structure defintion

Please Log in or Create an account to join the conversation.

More
1 year 11 months ago #292 by Bruce Armstrong
Bruce Armstrong replied the code: Two Factor Authentication

Thierry Garrigues wrote: Hi
Do you have information or code samples to integrate this example with Google's authentication APIs?
Regards


Perhaps you could post your question with additional information about what you're trying to do in the forums.

Please Log in or Create an account to join the conversation.

More
1 year 11 months ago #291 by Thierry Garrigues
Thierry Garrigues replied the code: Two Factor Authentication
Hi
Do you have information or code samples to integrate this example with Google's authentication APIs?
Regards

Please Log in or Create an account to join the conversation.

More
1 year 11 months ago #290 by Bruce Armstrong
Bruce Armstrong replied the code: Two Factor Authentication
>>Regarding two-factor authentication with Google, could you explain which Google web APIs to call to connect to a Google account?

Two factor authentication doesn't use any Google account apis. The only google api call I make at all is to a charting api to generate the QR code.

Please Log in or Create an account to join the conversation.

More
1 year 11 months ago - 1 year 11 months ago #289 by Bruce Armstrong
Bruce Armstrong replied the code: Two Factor Authentication
>>can you implement this when you want to send emails from powerbuilder using google with smtp? Thanks a lot.

This has nothing to do with Google mail. If you're looking for code to send Google email from PowerBuilder I suggest you look at this code sample which does it through .Net called from PowerBuilder ( community.appeon.com/index.php/codeexcha...56-net-importer-demo ) or the PBNISMTP utility, which does it through PBNI ( github.com/bruce-armstrong/pbnismtp )
Last Edit: 1 year 11 months ago by Bruce Armstrong.

Please Log in or Create an account to join the conversation.

More
1 year 11 months ago #288 by Thierry Garrigues
Thierry Garrigues replied the code: Two Factor Authentication
Hi Bruce.
Regarding two-factor authentication with Google, could you explain which Google web APIs to call to connect to a Google account?
Thank you
Regards

Please Log in or Create an account to join the conversation.

More
2 years 2 weeks ago #287 by Guillermo Rolando
Guillermo Rolando replied the code: Two Factor Authentication
Hi,
can you implement this when you want to send emails from powerbuilder using google with smtp? Thanks a lot.

Please Log in or Create an account to join the conversation.

More
2 years 9 months ago #264 by Bruce Armstrong
Bruce Armstrong replied the code: Two Factor Authentication
>>I have it setup as a local external function
>>subroutine DoDragDrop ( string Files ) library "dragdropdemo.dll"

That's not how you use a .Net assembly from PowerBuilder. Please review the original article, because it indicates how you need to do it.

Better yet, just wait for 2019 R2. An enhancement in that version will allow you to consume a .Net assembly without having to do the plumbing required through the technique I provided in that article.

Please Log in or Create an account to join the conversation.

More
2 years 9 months ago #263 by Rick Domogalik
Rick Domogalik replied the code: Two Factor Authentication
I was able to get the C# assembly compiled. When I call DoDragDrop() from PowerBuilder I get an error calling the external function DoDragDrop.

I have it setup as a local external function
subroutine DoDragDrop ( string Files ) library "dragdropdemo.dll"

dragdropdemo.dll is in the local directory where the program files are.

in a clicked event of a button (for test purposes)
dodragdrop( "c:\pdf\1.pdf")

On the click I get the error. "Error calling external function DoDragDrop at line 3 in clicked event of object cb_1.

Here is the C# code I am using. Pretty much the same as what you posted below. I did change DoDragandDrop to just DoDragDrop so it would match control.dodragDrop below. Not sure if this is correct, but trying it both ways lends the same error. I was able to compile this in SnapDevelop when I installed the new .NET 3.0 that just came out and reference the assembly System.Windows.Forms.

using System;
using System.Windows.Forms;
using System.Collections.Specialized;

namespace DragDropDemo
{

public class DragDrop
{
public void DoDragDrop(string filename)
{
StringCollection files = new StringCollection();
files.Add(filename);
DataObject dataObject = new DataObject();
dataObject.SetFileDropList(files);
Control control = new System.Windows.Forms.Control();
control.DoDragDrop(dataObject, System.Windows.Forms.DragDropEffects.Copy);
}
}
}


Any help would be much appreciated. Brand new to C# and the struggle is real.....

Rick

Please Log in or Create an account to join the conversation.

More
2 years 9 months ago #260 by Bruce Armstrong
Bruce Armstrong replied the code: Two Factor Authentication
Ah, need to make a correction in my last response. I forgot that the solution I provided references Windows.Forms (even for the CCW used by native PowerBuilder). The SnapDevelop IDE that Appeon provides only targets .Net Core and .Net Standard. Windows Form is (not yet) part of .Net Core or .Net Standard. There is a preview of .Net Core 3.0 available that includes it, but for now that means we can't use SnapDevelop. It also means we can't use Visual Studio Code either.

In any event, here's that C# code I had for the PowerBuilder CCW, but in plain C# rather than the modified syntax that PowerBuilder.Net used. If you're using Visual Studio, you just add a reference to the Windows.Forms assembly and use code similar to this:

using System;
using System.Windows.Forms;
using System.Collections.Specialized;

namespace DragAndDropDemo
{
public class DragAndDrop
{
public void DoDragAndDrop(string filename)
{
StringCollection files = new StringCollection();
files.Add(filename);
DataObject dataObject = new DataObject();
dataObject.SetFileDropList ( files ) ;
Control control = new System.Windows.Forms.Control();
control.DoDragDrop(dataObject, System.Windows.Forms.DragDropEffects.Copy);
}
}
}

I did verify it compiles. I didn't go as far as to create it as a CCW or attempt to use it.

Please Log in or Create an account to join the conversation.

More
2 years 9 months ago #259 by Rick Domogalik
Rick Domogalik replied the code: Two Factor Authentication
Bruce,

Thanks for the response. After some checking I have determined that the version of PowerBuilder I subscribe to does not include the C# editor. I can upgrade to the Cloud version and get it, just not sure if that is the correct course to take. I also checked into Visual Studio Code. I am very comfortable coding in PowerBuilder, but Visual studio Code seems like a steep learning curve to get up to speed on for me. In your opinion, would using the C# editor from Appeon be easier for someone who is familiar with PowerBuilder? Just trying to determine the best way to move forward with my project and either get up to speed with Visual Studio or Upgrade to the Cloud account with Appeon and use their C# editor.

Also, would you happen to have any examples of the assemblies to enable the drag/drop functionality with PowerBuilder and Windows Explorer? I tend to learn best looking at an example piece of code.

Thanks for your help!

Rick

Please Log in or Create an account to join the conversation.

Moderators: Appeon Administrator