ASWebAuthenticationSession completionHandler not called on clicking Authorize button in Strava Authentication. below given is my code.(used Using ASWebAuthenticationSession to connect to Strava account fails this link to implement.)
import AuthenticationServices
class LinkAppsViewController: UIViewController, ASWebAuthenticationPresentationContextProviding{
func authenticate()
{
let string = self.createWebAuthUrl()
guard let url = URL(string: string) else { return }
self.authSession = ASWebAuthenticationSession(url: url, callbackURLScheme: "localhost/", completionHandler:
{
url, error in
})
self.authSession!.presentationContextProvider = self
self.authSession?.start()
}
fileprivate func createWebAuthUrl() -> String
{
var url = String.init()
url.append("https://www.strava.com/oauth/mobile/authorize")
url.append("?client_id=<client id>")
url.append("&redirect_uri=http://localhost/exchange_token")
url.append("&response_type=code")
url.append("&approval_prompt=force")
url.append("&grant_type=authorization_code")
url.append("&scope=activity:write,activity:read_all")
return url
}
func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
print(session)
return view.window!
}
}