1. mike S
  2. SnapDevelop
  3. Sunday, 21 August 2022 14:53 PM UTC

To authenticate using JWT i need to connect to a user database to get the username/password .  This conneciton information is already stored by powerserver in the new PS2022 tables, and PS already knows how to connect to those databases since it handles all the rest apis for PS.

 

So, how can i connect using the PS datacache name in c#/snap so i can read from my user setup table?

Accepted Answer
Francisco Martinez @Appeon Accepted Answer Pending Moderation
  1. Monday, 22 August 2022 15:12 PM UTC
  2. SnapDevelop
  3. # Permalink
I see! I'll send this post to the engineering team to see if there's a direct way to achieve what you want.
Comment
There are no comments made yet.
Francisco Martinez @Appeon Accepted Answer Pending Moderation
  1. Monday, 22 August 2022 14:13 PM UTC
  2. SnapDevelop
  3. # 1

Hi Mike,

Forgive me if I'm misunderstanding the question and please correct me if I'm wrong:

What you want to do is get the connection configuration that PowerServer is using for the configuration tables?
In PowerBuilder: you could create your own endpoint that returns the contents of the AppConfig.json file (where you placed the database configuration for these tables).

In C# (Inside PowerServer itself): You can read the AppConfig.json file yourself by doing:

var appConfig = new ConfigurationBuilder()
                .AddJsonFile(".\\AppConfig\\AppConfig.json")
                .Build();

var connectionString = appConfig.GetSection("ConnectionStrings")["AppConfig"];
// connectionString contains the connection string you input in that file
using var dataContext = new DefaultDataContext(connectionString);
var executor = dataContext.SqlExecutor;
var connection = executor.Select<dynamic>("{SQL Query to access the data you want}")
    .FirstOrDefault();
if (connection != null)
{
    // connection.<column names>;
}

in an place that gets executed when you configure JWT

Hope this helps.

Regards,
Francisco

 

Comment
  1. mike S
  2. Monday, 22 August 2022 14:22 PM UTC
that is exactly what i want to do.



i assumed there was a method in some PS C# library that would take the cachename and return a connection transaction. i assumed this method would figure out how to get it and apply it to the connection. By using a PS method i would not have to handle making changes in table names, structures, etc. should anything change in the future since PS needs to do this anyway.
  1. Helpful
  1. mike S
  2. Monday, 22 August 2022 14:25 PM UTC
But in this particular case the connection information is stored in those powerserver tables not in JSON.



My assumption is that the PS C# stuff handles this already and i just want to use the same PS c# rather than have to do basically the same thing myself and have to maintain it when changes are made in PS C#
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.