我是新的azure。我正在建立本地iOS应用程序,有电子邮件登录/注册使用蓝色活动目录B2C。我能够登录和注册,但问题是,重定向网址不是working.On成功登录或signup我仍然在浏览器上,而是返回到我的应用程序。
代码
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部分添加了到azure web-portal的重定向url。
发布于 2017-08-23 07:11:14
你的重定向网址应该看起来像com.onmicrosoft.contoso.appname://redirect/path.有关如何注册本机应用程序和配置重定向URI的说明,请参阅this page。
我还在认证/授权->允许的外部重定向url部分添加了到azure web门户的重定向url。
那不是正确的地方。请按照上述链接中的步骤操作。
https://stackoverflow.com/questions/45813909
复制相似问题