问题
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