-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
Automatically accept TOU #550
Conversation
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.
Self-review
@@ -509,7 +565,7 @@ private struct LibreLinkResponseGlucose: Codable { | |||
// MARK: - LibreLinkResponseUser | |||
|
|||
private struct LibreLinkResponseUser: Codable { | |||
let id: String |
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.
When prompted for terms, the id is missing.
@@ -188,7 +188,20 @@ class LibreLinkUpConnection: SensorBluetoothConnection, IsSensor { | |||
if lastLogin == nil || lastLogin!.authExpires <= Date() { | |||
DirectLog.info("LibreLinkUp processLogin, starts working, \(Date().debugDescription)") | |||
|
|||
let loginResponse = try await login(apiRegion: apiRegion) | |||
var loginResponse = try await login(apiRegion: apiRegion) | |||
if loginResponse.status == 4 { |
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.
AFAIK a status of 4 means we need to accept terms. I could also type the step
object so that I could do loginResponse.data.step.type == "tou"
here, but this works.
throw LibreLinkError.missingUserOrToken | ||
} | ||
|
||
loginResponse = try await tou(apiRegion: apiRegion, authToken: authToken) |
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.
We do need the token.
if let apiRegion = apiRegion { | ||
urlString = "https://api-\(apiRegion).libreview.io/auth/continue/tou" | ||
} else { | ||
urlString = "https://api.libreview.io/auth/continue/tou" |
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.
All we need is a POST
to this endpoint, and pass along the token.
DirectLog.info("LibreLinkUp tou, response: \(String(data: data, encoding: String.Encoding.utf8))") | ||
|
||
if statusCode == 200 { | ||
return try decode(LibreLinkResponse<LibreLinkResponseLogin>.self, data: data) |
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.
The response is identical to login.
Thank you so much <3, I haven't had enough time the last few months, I'll have a look at the PR. I will do that in the next few days. Many greetings |
Sometimes, login can ask to accept terms, and will not return the user ID we need, nor respond to later requests for data until the terms have been accepted.
This PR handles that by automatically accepting the terms.
Closes #452