ASWebAuthenticationSession completionHandler が、Strava 認証の [承認] ボタンをクリックしても呼び出されない。以下は私のコードです。
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!
}
}