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

时间:2019-01-01 06:13:10

标签: ios swift adfs msal

我想使用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"

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

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

  

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方法中获取该代码,然后我们需要使用以下参数创建发布请求:

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

就是这样。我们将获得access_token,可以将其进一步用于获取userProfile等。

希望这会有所帮助!

相关问题