Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change ID from Int to String to support gear_id #30

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Updated StravaClient so no crash on token retrieve fail
FleetPhil committed Jan 4, 2021
commit b65e16a167c5d7da88f503a0b17f4d17647b559e
12 changes: 9 additions & 3 deletions Sources/StravaSwift/StravaClient.swift
Original file line number Diff line number Diff line change
@@ -207,13 +207,19 @@ extension StravaClient: ASWebAuthenticationPresentationContextProviding {
- Parameter code: the code (string) returned from strava
- Parameter result: a closure to handle the OAuthToken
**/
// Edited to check response before force unwrap of the token as errors cause crash
private func getAccessToken(_ code: String, result: @escaping AuthorizationHandler) {
do {
try oauthRequest(Router.token(code: code))?.responseStrava { [weak self] (response: DataResponse<OAuthToken>) in
guard let self = self else { return }
let token = response.result.value!
self.config?.delegate.set(token)
result(.success(token))
switch response.result {
case .success:
let token = response.result.value!
self.config?.delegate.set(token)
result(.success(token))
case .failure(let error):
result(.failure(error))
}
}
} catch let error as NSError {
result(.failure(error))