Skip to content
This repository was archived by the owner on Jun 10, 2025. It is now read-only.

Commit 7dd5b82

Browse files
authored
Replace login.microsoftonline.com w/b2clogin.com
This is the correct endpoint for the tenant using b2c: https://fabrikamb2c.b2clogin.com/fabrikamb2c.onmicrosoft.com/b2c_1_susi/v2.0/.well-known/openid-configuration Not sure if the fixed I did are correct, or if there are tests, but i think something like this should unblock the customers reporting issues w/this sample. cc: @jmprieur @oldalton
1 parent 473303d commit 7dd5b82

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

MSALiOSB2C/ViewController.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import MSAL
3434
class ViewController: UIViewController, UITextFieldDelegate, URLSessionDelegate {
3535

3636
let kTenantName = "fabrikamb2c.onmicrosoft.com" // Your tenant name
37+
let kAuthorityHostName = "fabrikamb2c.b2clogin.com" // Your authority host name
3738
let kClientID = "90c0fe63-bcf2-44d5-8fb7-b8bbc0b29dc6" // Your client ID from the portal when you created your application
3839
let kSignupOrSigninPolicy = "b2c_1_susi" // Your signup and sign-in policy you created in the portal
3940
let kEditProfilePolicy = "b2c_1_edit_profile" // Your edit policy you created in the portal
@@ -42,7 +43,7 @@ class ViewController: UIViewController, UITextFieldDelegate, URLSessionDelegate
4243
let kScopes: [String] = ["https://fabrikamb2c.onmicrosoft.com/helloapi/demo.read"] // This is a scope that you've configured your backend API to look for.
4344

4445
// DO NOT CHANGE - This is the format of OIDC Token and Authorization endpoints for Azure AD B2C.
45-
let kEndpoint = "https://login.microsoftonline.com/tfp/%@/%@"
46+
let kEndpoint = "https://%@/tfp/%@/%@"
4647

4748
var application: MSALPublicClientApplication!
4849

@@ -364,7 +365,7 @@ class ViewController: UIViewController, UITextFieldDelegate, URLSessionDelegate
364365
use for the current user flow.
365366
*/
366367
func getAuthority(forPolicy policy: String) throws -> MSALB2CAuthority {
367-
guard let authorityURL = URL(string: String(format: self.kEndpoint, self.kTenantName, policy)) else {
368+
guard let authorityURL = URL(string: String(format: self.kEndpoint, self.kAuthorityHostName, self.kTenantName, policy)) else {
368369
throw NSError(domain: "SomeDomain",
369370
code: 1,
370371
userInfo: ["errorDescription": "Unable to create authority URL!"])

0 commit comments

Comments
 (0)