SweetzpotAS / StravaZpot-Swift

An API to integrate with Strava on iOS apps
21 stars 7 forks source link

Concrete Examples #2

Closed bleeckerj closed 6 years ago

bleeckerj commented 6 years ago

Do you have any concrete examples of using the Authentication API? The Test code isn't entirely clear to me how you handle the result and extract the token.

truizlop commented 6 years ago

Read the Readme, it is documented there.

On 20 Apr 2018, at 21:27, Julian Bleecker notifications@github.com wrote:

Do you have any concrete examples of using the Authentication API? The Test code isn't entirely clear to me how you handle the result and extract the token.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

bleeckerj commented 6 years ago

Indeed, and I've made some progress, but continue to get errors indicating I should refresh my Token and no real indication as to how to do that, or examples of semantic error handling.

truizlop commented 6 years ago

There is also an app folder in this repo with an example on how to authenticate and extract the token.

bleeckerj commented 6 years ago

I honestly appreciate the comments and pointers — I do not see an app folder in the repo. All I see are the extensive source code and the StravaZpotTests. Can you point where you mean?

truizlop commented 6 years ago

I'm sorry, I got confused with the Android repo, which has a sample app folder.

I'm not sure what's the issue you are having, the README is quite descriptive about how to proceed. I guess you have created an AuthenticationViewController as described here. Then you need to create your delegate implementing this method:

func authenticationViewController(_ authenticationViewController: AuthenticationViewController, didFinishWithCode code: String) {
  // Use code to obtain token
}

The implementation inside this method should be according what is explained here. In order to check if the result was successful or not, you can do something like:

func processLogin(result : StravaResult<LoginResult>) {
  switch result {
  case let .success(login): ... // Save the token in the LoginResult
  case let .error(cause): ... // Process the error
  }
}

I insist, all this is described in the README. Beyond this, it is up to your app how to proceed with saving the token and using it.