Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C# to Python help
#1
Hello

I want to write this same code in c# on python code :

var generateTokenRequestParameters = new GenerateTokenRequest("View", null, identities: new List<EffectiveIdentity> { new EffectiveIdentity(username: "myUserName", roles: new List<string> { "FranceSales" }, datasets: new List<string> { "382ea16c-fbcc-4cec-bb60-470aff4aebaa" }) });
Any help ?
Reply
#2
Since that is a C# for Azure command, suggest you start here: https://docs.microsoft.com/en-us/python/...ure-python

also see: https://pypi.python.org/pypi?%3Aaction=s...mit=search
Reply
#3
Thank you for your reply, this is good but if some one could help me saving time it would be better :)

this is my python code :
class EmbedToken:
    def __init__(self, report_id, group_id, settings=None):
        self.username = '[email protected]'
        self.password = 'MyPassword'
        self.client_id = '28c7e68d-6eb1-4be3-8b97-4c0fa9cd83d6'
        self.report_id = report_id
        self.group_id = group_id
        if settings is None:
            #self.settings = {'accessLevel': 'View', 'allowSaveAs': 'false'}
            self.identitie = {'accessLevel': 'View','identities': [{'username': '[email protected]','roles': ['FranceSales'],'datasets': ['382ea16c-fbcc-4cec-bb60-470aff4aebaa']}]}
            print(self.identitie)
            self.settings = self.identitie
        else:
            self.settings = settings
When I add identities to json settings it's not working .
Reply
#4
you should encrypt first, then save as json
This code not tested, but should work or only need minor modification.
at top:
import json
after line 14:

        self.save_settings(filename)

def save_settings(self, filename):
    with filename.open('w') as f:
        json.dump(self.settings, f)

# for reading back in:
def load_file(self, filename):
    with filename.open('r') as f:
        self.settings = json.load(f)
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020