mirror of
https://github.com/OAuthSwift/OAuthSwift.git
synced 2026-04-26 12:45:52 +03:00
[GH-ISSUE #139] Error with Fitbit Oauth 2.0 #86
Labels
No labels
bug
cocoapod
duplicate
enhancement
feature-request
help wanted
help wanted
invalid
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/OAuthSwift#86
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @fnk0 on GitHub (Nov 8, 2015).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/139
So... Fitbit switched from Oauth 1.0 to 2.0... and one of the problems with their new oauth is that it requires a Basic authentication header for the token exchange.
As described in their docs the authentication for the header should follow the following standards:
Authorization Header
The Authorization header must be set to Basic followed by a space, then the Base64 encoded string of your application's client id and secret concatenated with a colon. For example, the Base64 encoded string, Y2xpZW50X2lkOmNsaWVudCBzZWNyZXQ=, is decoded as "client_id:client secret".
They also use Form url encoded...
Here's a example of the header for the token exchange.
The errors that I receive when trying to exchange the token are:
@phimage commented on GitHub (Nov 9, 2015):
maybe a workaround, did you try with a url like this into access_token_url
https://client_id:client secret@api.fitbit.com/oauth2/token
anyway the
postOAuthAccessTokenWithRequestTokenByCodesend secret using query stringWe must find a cool way to allow custom header ie. change "Bearer : token" by "Basic: base64(clientid:secret)"
Can add an enum param
which modify parameters["grant_type"] = "authorization_code" to "password"
then client and credential must check the type before creating headers
http://tools.ietf.org/html/draft-ietf-oauth-v2-23
4.3. Resource Owner Password Credentials Grant
@phimage commented on GitHub (Nov 18, 2015):
Read from FiBit doc
so we must do it ;)
not password grant
you can try with "token"
I think I make confusion between Auth headers used for the auth flow, and the Auth headers used after auth (to make api call)
In RFC Auth headers are not mandatory for auth, but sometime necessary and will be Basic one
see 4.1.3. Access Token Request
http://tools.ietf.org/html/draft-ietf-oauth-v2-23
Doing this just to get token work (but I can commit because other api could failed)
I will add an handler type with this controller as example or into framework
edit:
11424b643a@phimage commented on GitHub (Nov 19, 2015):
see
b74da75I add
accessTokenBasicAuthentificationand use in demo code for FitBit and Oauth2@amruss commented on GitHub (Jan 26, 2016):
This was awesome, thank you!