How to implement SSO functionality on IOS using ADFS

荒凉一梦 提交于 2019-12-09 20:59:37

问题


I want to implement the single sign-on functionality on IOS using ADFS. I did some R&D and tried the MSAL iOS library for ADFS authentication but it's not working for me.

I have added client id, Authority URL for ADFS authentication but it's not working for me. Every time its give me Couldn't acquire token error.

I have different SSO URL, so not using Microsoft azure server.

I have tried to add my credential in following way for MSAL IOS library

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"

Any Idea?


回答1:


Here we do not need to use MSAL iOS. There is a simple solution using Microsoft docs . Following the link :

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

We just need to form a url string

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

This will generate a code which we can fetch in openUrl method in App Delegate and then we need to create a post request with the parameters :

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

That's it . We will get the access_token which we can use further to get userProfile etc.

Hope this helps!



来源:https://stackoverflow.com/questions/53993393/how-to-implement-sso-functionality-on-ios-using-adfs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!