[英]Azure email login signup b2c iOS swift
我是Azure的新手,正在构建本机iOS应用程序,该应用程序使用azure活动目录B2C进行电子邮件登录/注册。我能够登录和注册,但问题是重定向网址不起作用。成功登录或注册后我仍然在浏览器上,而不是回到我的应用程序。
码
let kTenantName = "AppName"
let kSignupOrSigninPolicy = "B2C_1_signupPolicy"
let kClientId = "clientId"
let kRedirectUri = "https://appname.azurewebsites.net/.auth/login/aad/callback"
let kEndpoint = "https://login.microsoftonline.com/........"
@IBAction func bt_login(sender: UIButton) {
print("Signing in")
let authorizationEndpoint = NSURL(string: kEndpoint)!
let tokenEndpoint = NSURL(string: kEndpoint)!
let configuration = OIDServiceConfiguration(authorizationEndpoint: authorizationEndpoint, tokenEndpoint: tokenEndpoint)
let request = OIDAuthorizationRequest(configuration: configuration, clientId: kClientId, scopes: [OIDScopeOpenID, OIDScopeProfile], redirectURL: NSURL(string: kRedirectUri)!, responseType: OIDResponseTypeCode, additionalParameters: nil)
var appDelegate = (UIApplication.sharedApplication().delegate! as! AppDelegate);
appDelegate.currentAuthorizationFlow = OIDAuthState.authStateByPresentingAuthorizationRequest(request, presentingViewController: self) { (authState, error) in
if (authState != nil) {
print("Got ID token: \(authState!.lastTokenResponse!.idToken)")
}
else {
print("Authorization error: \(error!.localizedDescription)")
}
}
我在info.plist
文件中添加了相同的重定向URL。 另外,我在Authentication/Authorization->ALLOWED EXTERNAL REDIRECT URLS
部分中将重定向URL添加到了Azure Web门户。
您的重定向URL应为com.onmicrosoft.contoso.appname:// redirect / path。 请参阅此页面以获取有关如何注册本机应用程序和配置重定向URI的说明。
另外,我在Authentication / Authorization-> ALLOWED EXTERNAL REDIRECT URLS部分中将重定向URL添加到了Azure Web门户。
那不是正确的地方。 请按照上面的链接中的步骤。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.