mirror of https://github.com/tasks/tasks
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
494 B
Kotlin
18 lines
494 B
Kotlin
package org.tasks.auth
|
|
|
|
import android.util.Base64
|
|
import org.json.JSONObject
|
|
|
|
class IdToken(idToken: String) {
|
|
private val parts: List<String> = idToken.split(".")
|
|
private val json = JSONObject(String(Base64.decode(parts[1], Base64.DEFAULT)))
|
|
|
|
val email: String?
|
|
get() = json.optString("email").takeIf { it.isNotBlank() }
|
|
|
|
val sub: String
|
|
get() = json.getString("sub")
|
|
|
|
val login: String?
|
|
get() = json.optString("login").takeIf { it.isNotBlank() }
|
|
} |