如何使用ADFS在IOS上实现SSO功能

问题描述 投票:2回答:1

我想使用single sign-onIOS上实现ADFS功能。我做了一些研发并尝试了MSAL iOS库进行ADFS身份验证,但它对我不起作用。

我添加了客户端ID,ADFS身份验证的权限URL,但它不适用于我。每次它给我Couldn't acquire token错误。

我有不同的SSO URL,所以不使用Microsoft azure server

我试图以下列方式为MSAL IOS库添加我的凭证

let kClientID = "xxxxxx-8929-4D60-B869-xxxxxxxx"

// These settings you don't need to edit unless you wish to attempt deeper scenarios with the app.
let kGraphURI = "https://graph.microsoft.com/v1.0/me/"
let kScopes: [String] = ["https://graph.microsoft.com/user.read"]
let kAuthority = "https://fs.example.com/adfs/oauth2"

任何的想法?

ios swift adfs msal
1个回答
1
投票

这里我们不需要使用MSAL iOS。有一个使用Microsoft文档的简单解决方案。点击链接:

https://docs.microsoft.com/en-us/windows-server/identity/ad-fs/overview/ad-fs-scenarios-for-developers

我们只需要形成一个url字符串

https://fs.xxx.com/adfs/oauth2/authorize?response_type=code&client_id=xxxx-xxxx-xxxx-xxxx-xxxxxxx&redirect_uri=appName://&resource=http://xxxx/workflow

这将生成一个代码,我们可以在App Delegate中的openUrl方法中获取,然后我们需要创建一个带有参数的post请求:

grant_type:authorization_code
code: xxxxx ( we got from get request)
redirect_uri: appName://
resource:http://xxxx/workflow

而已 。我们将获得access_token,我们可以进一步使用它来获取userProfile等。

希望这可以帮助!

© www.soinside.com 2019 - 2024. All rights reserved.