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
Fix token expiry date #33
Conversation
To enable access of credentials in case of token refresh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're missing some upstream changes too; check out the changes in your PR to Twift.swift
.
Also see my comment on #32; I think we need to encode expiresAt
since expiresIn
by itself is no use when decoding at an arbitrary later date.
internal func fieldsOnly<T: Fielded>(for type: T.Type, fields: Set<T.Field>) -> [URLQueryItem] { | ||
var queryItems: [URLQueryItem] = [] | ||
|
||
if !fields.isEmpty { queryItems.append(URLQueryItem(name: T.fieldParameterName, value: fields.compactMap { T.fieldName(field: $0) }.joined(separator: ","))) } | ||
|
||
return queryItems | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the advantage of this over fieldsAndExpansions
?
fields: Set<Tweet.Field> = [], | ||
userFields: Set<User.Field> = [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I see what's happened here; we should make fields
a Set<List.Field>
instead of introducing a userFields
property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, never made these changes myself 😂 messed up the update and had some local git issues.
Oh wow, messed up the PR completely, I was sure I checked but it's not up to date at all. I will close it and re-do in the next few days 🙌 |
I just came back from the vacation, sry to have completely spaced this 😅, never got to correcting the PR. |
I think I fixed this in 2d518d1, feel free to verify in your project! |
ohhh this looks nice, will check 🙌 |
As detailed in this issue, token was getting new date on every encode/decode, therefore never expiring.
This PR omits setting the
expiresAt
date and tries to only set it during first authentication and refresh.After this, we might want to explore the option of a force refresh if 401 response is received.
That way expiry would never really need to be logged as we can always try with the old token and refresh if the bad response is received.