You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import MSAL
class ViewController: UIViewController {
let clientID = "your_client_id"
let redirectUri = "your_redirect_uri"
let authority = "https://login.microsoftonline.com/common"
override func viewDidLoad() {
super.viewDidLoad()
do {
let msalConfig = try MSALPublicClientApplicationConfig(clientId: clientID, redirectUri: redirectUri, authority: MSALAuthority(url: URL(string: authority)!))
let applicationContext = try MSALPublicClientApplication(configuration: msalConfig)
let webViewParameters = MSALWebviewParameters(parentViewController: self)
let parameters = MSALInteractiveTokenParameters(scopes: ["User.Read"], webviewParameters: webViewParameters)
applicationContext.acquireToken(with: parameters) { (result, error) in
if let error = error {
print("Could not acquire token: \(error.localizedDescription)")
return
}
guard let authResult = result else {
print("Auth result is nil")
return
}
print("Access token is \(authResult.accessToken ?? "No access token")")
print("Refresh token is \(authResult.refreshToken ?? "No refresh token")")
// Log all properties of the auth result for debugging
print("Authorization response: \(authResult.authorizationHeader ?? "No authorization header")")
print("ID Token: \(authResult.idToken ?? "No ID token")")
print("Scopes: \(authResult.scopes)")
print("Expires on: \(authResult.expiresOn ?? Date())")
}
} catch {
print("Error creating MSALPublicClientApplication: \(error)")
}
MSALGlobalConfig.loggerConfig.setLogCallback { (logLevel, message, containsPII) in
if !containsPII {
print("%@", message ?? "No message")
}
}
}
}
I need authResult.refreshToken which I need to be give to server to fetch all Calendar related data without the help of client all the time but I'm unable to fetch the refresh token
Scopes Given : "User.Read" , "Calendars.ReadWrite" & "Offline_access"
On Azure Portal
Please help to fix this one ☝️
The text was updated successfully, but these errors were encountered:
Hello @alpha-sagar, looking at your provided sample, I'm not seeing a silent token request. In order to use the refresh token for a silent authentication, you should first call acquireTokenSilent.
See the implementation in this sample as a guide. First check if a silent token acquisition is possible, and then acquire interactively if needed.
I'm using like this :
I need authResult.refreshToken which I need to be give to server to fetch all Calendar related data without the help of client all the time but I'm unable to fetch the refresh token
Scopes Given :
"User.Read" , "Calendars.ReadWrite" & "Offline_access"
On Azure Portal
Please help to fix this one ☝️
The text was updated successfully, but these errors were encountered: