def get_credential(self, auth_record=None, user_client_id=None, tenant_id=None) -> InteractiveBrowserCredential: ''' Raises ------ ValueError If PyGObject is not installed in the host Linux OS. ''' profile = read_profile() user_cloud = profile.get('cloud', None) cloud_authority = user_cloud.get('azure_ad_endpoint', None) authority = cloud_authority or DEFAULT_AUTHORITY client_id = user_client_id or DEFAULT_CLIENT_ID # Once a user is authenticated they get an auth_record object which will have the authority and client_id # therefore we don't need to pass authority and client_id to InteractiveBrowserCredential. if auth_record: return InteractiveBrowserCredential( enable_persistent_cache=True, allow_unencrypted_cache=False, authentication_record=auth_record, ) # Passes authority and client_id when the user doesn't have an auth record return InteractiveBrowserCredential( authority=authority, client_id=client_id, tenant_id=tenant_id, enable_persistent_cache=True, allow_unencrypted_cache=False, )
def show_profile(): profile = read_profile() # remove user_defined_clouds from the profile local variable. # The user wants to see just the cloud and version information. profile.pop('user_defined_clouds') return profile
def select_version(): supported_versions = ['v1.0', 'beta'] profile = read_profile() selected = prompt_choice_list('Select graph version', supported_versions) selected_version = supported_versions[selected] profile.update({'version': selected_version}) write_profile( profile, error_msg='An error occured while setting the selected version') print(f'Version {selected_version} selected')
def _get_version(): return read_profile().get('version', 'v1.0')
def _get_endpoint(): cloud = read_profile().get('cloud', DEFAULT_BASE_URL) return cloud.get('graph_endpoint')
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- import pkgutil from knack.cli import logger from importlib import import_module from collections import OrderedDict from knack.arguments import ignore_type from knack import CLICommandsLoader from msgraph.cli.core.commands._util import _load_module_command_loader, _load_extension_command_loader from msgraph.cli.core.profile import read_profile version = read_profile().get('version', 'v1.0') if version == 'v1.0': from msgraph.cli.core.v1_0_installed_extensions import installed_extensions else: from msgraph.cli.core.beta_installed_extensions import installed_extensions class MainCommandsLoader(CLICommandsLoader): """ Loads command_tables from command_modules. """ def __init__(self, cli_ctx=None): super(MainCommandsLoader, self).__init__(cli_ctx) self.cmd_to_loader_map = {} self.loaders = []