mirror of
https://github.com/OAuthSwift/OAuthSwift.git
synced 2026-04-26 20:55:57 +03:00
[GH-ISSUE #569] How do I set the token expiration date for OAuth 2.0 with Implicit Grant Flow? #371
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#371
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 @aholsteinson on GitHub (Jan 24, 2020).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/569
Description:
I am using the Fitbit API to authorize my app and it is working fine however in the OAuthSwift documentation I don't see a way to set the expiration date of the generated token even tho the Fitbit API has a method to do so and the Implicit Grant Flow lets you set the expiration date to up to a year.
Here is my config for oAuthSwift:
let config = OAuth2Swift( consumerKey: Constants.FitbitApi.consumerKey, consumerSecret: Constants.FitbitApi.consumerSecret, authorizeUrl: Constants.FitbitApi.authorizeUrl, accessTokenUrl: Constants.FitbitApi.accessTokenUrl, responseType: Constants.FitbitApi.responseType )Per de documentations those are the parameters it takes but no expiration date parameter. And here is my authorization method:
` @IBAction func doOAuthFitbit(sender: AnyObject) {
let oauthswift = FitbitOAuth.sharedInstance.config
oauthswift.accessTokenBasicAuthentification = true
FitbitOAuth.sharedInstance.oauthswift = oauthswift
As noted this is working fine however the token always comes with an expiration date of 277895 and I would like to set it to 30 days or a year.
Thanks in advance.
OAuth Provider? (Twitter, Github, ..):
Fitbit
OAuth Version:
OS (Please fill the version) :
Installation method:
Library version:
Xcode version:
11.x (Swift 5.1)
10.x (Swift 5.0)
10.x (Swift 4.1)
9.3 (Swift 4.1)
9.0 (Swift 4.0)
other: (Please fill in the version you are using.)
objective c
@phimage commented on GitHub (Jan 27, 2020):
Hi
Fit bit api link about that please.
Sometimes token duration is defined on website interface
@aholsteinson commented on GitHub (Jan 27, 2020):
Hi, here is the link to the Fitbit API documentation on oAuth 2:
https://dev.fitbit.com/build/reference/web-api/oauth2/
You can see that they let you specify a "expires_in" parameter when using Implicit Grant Flow.
@phimage commented on GitHub (Jan 27, 2020):
you can try by adding to the parameter
parametersgithub.com/OAuthSwift/OAuthSwift@6ba5b8dd9f/Sources/OAuth2Swift.swift (L83)parameters: ["expires_in": 3600]@aholsteinson commented on GitHub (Jan 27, 2020):
@phimage thanks, that worked!
Much appreciated.