public BrokerClientExecutionHandler( IB2CAuthService authService, string resourceTokenBrokerUrl, ICacheSingleObjectByKey resourceTokenCache = null) { _authService = authService ?? throw new NoNullAllowedException("B2C Authentication Service construction parameter cannot be null"); _brokerTransportClient = new BrokerClientTransportHandler(resourceTokenBrokerUrl); _resourceTokenCache = resourceTokenCache; }
public MainPage() { const string defaultNameSpace = "XamarinForms.Client"; var assembly = typeof(App).GetTypeInfo().Assembly; // Loading the file that have been marked as an Embedded Resource var fileStream = assembly.GetManifestResourceStream($"{defaultNameSpace}.msalconfig.json"); if (!(fileStream is null)) { using var reader = new StreamReader(fileStream); var jsonStr = reader.ReadToEnd(); var configObject = JObject.Parse(jsonStr); var b2cHostName = configObject["B2CHostName"].ToString(); var tenantId = configObject["TenantId"].ToString(); var clientId = configObject["ClientId"].ToString(); var signUpSignInFlowName = configObject["SignUpSignInFlowName"].ToString(); var resourceTokenBrokerUrl = configObject["ResourceTokenBrokerUrl"].ToString(); var scopes = ((JArray)configObject["Scopes"])?.Select(scope => scope?.ToString()); var iOSChainGroup = "com.microsoft.adalcache"; Func <bool> isAndroidDeviceFunc = () => DeviceInfo.Platform == DevicePlatform.Android; Func <bool> isiOSDeviceFunc = () => DeviceInfo.Platform == DevicePlatform.iOS || DeviceInfo.Platform == DevicePlatform.watchOS || DeviceInfo.Platform == DevicePlatform.tvOS; Func <object> getAndroidParentWindowFunc = () => DependencyService.Get <IParentWindowLocatorService>().GetCurrentParentWindow(); _authService = new B2CAuthService( b2cHostName, tenantId, clientId, signUpSignInFlowName, scopes, iOSChainGroup, isAndroidDeviceFunc, isiOSDeviceFunc, getAndroidParentWindowFunc); var quickAndDirtyPermissionsTokenCache = new QuickAndDirtyCache(); _cosmosTokenClient = new CosmosTokenClient(_authService, resourceTokenBrokerUrl, quickAndDirtyPermissionsTokenCache); } InitializeComponent(); }
/// <summary> /// <para> /// Instance of Cosmos token client. /// </para> /// </summary> /// <param name="authService">Azure AD B2C authentication service.</param> /// <param name="resourceTokenBrokerUrl">Url for the resource token broker</param> /// <param name="resourceTokenCache">Caching of token</param> public CosmosTokenClient( IB2CAuthService authService, string resourceTokenBrokerUrl, ICacheSingleObjectByKey resourceTokenCache = null) : base(authService, resourceTokenBrokerUrl, resourceTokenCache) { }