首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Azure电子邮件登录注册b2c iOS swift

Azure电子邮件登录注册b2c iOS swift
EN

Stack Overflow用户
提问于 2017-08-22 17:32:43
回答 1查看 195关注 0票数 0

我是新的azure。我正在建立本地iOS应用程序,有电子邮件登录/注册使用蓝色活动目录B2C。我能够登录和注册,但问题是,重定向网址不是working.On成功登录或signup我仍然在浏览器上,而是返回到我的应用程序。

代码

代码语言:javascript
复制
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。

EN

回答 1

Stack Overflow用户

发布于 2017-08-23 07:11:14

你的重定向网址应该看起来像com.onmicrosoft.contoso.appname://redirect/path.有关如何注册本机应用程序和配置重定向URI的说明,请参阅this page

我还在认证/授权->允许的外部重定向url部分添加了到azure web门户的重定向url。

那不是正确的地方。请按照上述链接中的步骤操作。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45813909

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档