Skip to content

Commit

Permalink
more changes to the scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
lalwani committed Mar 19, 2024
1 parent e75bff3 commit e78af6d
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 8 deletions.
1 change: 1 addition & 0 deletions authentication/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ android {

dependencies {
implementation(libs.appCompat)
implementation(libs.chrometabs)
implementation(libs.material)
implementation(libs.retrofit)
implementation(libs.retrofit.moshi)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package com.uber.sdk2.auth.api

import com.uber.sdk2.auth.api.internal.SsoLink
import com.uber.sdk2.auth.api.response.AuthResult

/** Provides a way to authenticate the user using SSO flow. */
Expand All @@ -26,5 +25,5 @@ interface AuthProviding {
* @param ssoLink The SSO link to execute.
* @return The result from the authentication flow encapsulated in [AuthResult]
*/
suspend fun authenticate(ssoLink: SsoLink): AuthResult
suspend fun authenticate(): AuthResult
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,20 @@ sealed class AuthException(override val message: String) : RuntimeException(mess

/** Represents the exception that occurred due to network error. */
data class NetworkError(override val message: String) : AuthException(message)

companion object {
val CANCELED: String = "Canceled"

val SCOPE_NOT_PROVIDED: String = "Scope not provided in the sso config file"

val REDIRECT_URI_NOT_PROVIDED: String = "Redirect URI not provided in the sso config file"

val AUTH_CODE_INVALID = "Invalid auth code"

val EMPTY_RESPONSE = "Response is empty"

val NULL_RESPONSE = "Response not received"

val UNKNOWN = "Unknown error occurred"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,23 @@ package com.uber.sdk2.auth.api.request

import android.content.Context
import android.content.res.Resources
import android.os.Parcelable
import com.uber.sdk2.auth.api.exception.AuthException
import com.uber.sdk2.core.config.UriConfig.CLIENT_ID_PARAM
import com.uber.sdk2.core.config.UriConfig.REDIRECT_PARAM
import com.uber.sdk2.core.config.UriConfig.SCOPE_PARAM
import java.io.IOException
import java.nio.charset.Charset
import kotlinx.parcelize.Parcelize
import okio.Buffer
import okio.BufferedSource
import okio.Okio
import org.json.JSONException
import org.json.JSONObject

data class SsoConfig(val clientId: String, val redirectUri: String, val scope: String? = null)
@Parcelize
data class SsoConfig(val clientId: String, val redirectUri: String, val scope: String? = null) :
Parcelable

object SsoConfigProvider {
fun getSsoConfig(context: Context): SsoConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import com.uber.sdk2.auth.api.exception.AuthException
/** Represents the response from the authentication request. */
sealed class AuthResult {
/** Represents the success response from the authentication request. */
data class Success(val authCode: String, val accessToken: AccessToken) : AuthResult()
data class Success(val uberToken: UberToken? = null) : AuthResult()

/** Represents the error response from the authentication request. */
data class Error(val authException: AuthException) : AuthResult()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,16 @@
*/
package com.uber.sdk2.auth.api.response

import android.os.Parcelable
import com.squareup.moshi.Json
import kotlinx.parcelize.Parcelize

/** Holds the OAuth token that is returned after a successful authentication request. */
data class OAuthToken(val accessToken: AccessToken, val refreshToken: String)
@Parcelize
data class UberToken(
val authCode: String? = null,
@Json(name = "access_token") val accessToken: String? = null,
@Json(name = "access_token") val refreshToken: String? = null,
@Json(name = "expires_in") val expiresIn: Long? = null,
@Json(name = "scope") val scope: String? = null,
) : Parcelable
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.uber.sdk2.auth.api.response
package com.uber.sdk2.auth.api.sso

/** Holds the access token that is returned after a successful authentication request. */
data class AccessToken(val token: String, val scope: String, val expiresIn: Long)
import kotlinx.coroutines.flow.Flow

/**
* Represents the Single Sign-On (SSO) link for authentication. This class is used to start the SSO
* flow
*/
interface SsoLink {
suspend fun execute(optionalQueryParams: Map<String, String>): Flow<String>
}

0 comments on commit e78af6d

Please sign in to comment.