Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Error 401: Authorization header required Swift

Hi Fitbit community,

 

So the error I am getting is:HTTP Status 401: Unauthorized, Response: {"errors":[{"errorType":"invalid_request","message":"Authorization header required. 

The code I have to authorize Fitbit is :

func authorizeFitbit(completion: (result: Bool) -> Void ){       
oauthswift
.accessTokenBasicAuthentification = true let state: String = generateStateWithLength(20) as String
oauthswift
.authorizeWithCallbackURL( NSURL(string: "xxxxxxxxx")!, scope: "xxxxxxxxxxxxx", state: state, success: {
credential
, response, parameters in self.getUserProfile(){ (result: Bool) in
completion
(result: result) } }, failure: { error in print(error.localizedDescription)
completion
(result: false) }) }

I am able to grab profile information but when I am trying to grab more information from fitbit by clicking on an IBAction button, I am required to use this authorize function again to grab the number of steps.

 

Best Answer
0 Votes
5 REPLIES 5

Hi @Zhanliang,

Just as a heads up, I've moved your post from the iOS forum to the API forum to help keep the Community organized.

The iOS forum is for discussing and seeking help for the iOS Fitbit App.

Welcome to the Community!

Derrick | Retired Moderator, Fitbit

Best Answer
0 Votes

bump

Best Answer
0 Votes

bump

Best Answer
0 Votes

bump.. Someone help me out pls

Best Answer
0 Votes

Repeatedly "bumping" a topic doesn't help anyone. Please don't do this.

 

This is a forum for getting help with the Fitbit Web API, not for help with the Swift programming language. I encourage you to do a Google search for how to make a HTTP request with an Authorization header using Swift.

Best Answer
0 Votes