Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Documentation/ConfigurationManagement.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Open `config.yaml` and fill in the required fields.
Example:

```yaml
API_HOST_URL: 'https://mylmsexample.com'
API_HOST_URL: 'https://4c1346f74eb5.ngrok-free.app'
APPLICATION_ID: 'org.openedx.app'
ENVIRONMENT_DISPLAY_NAME: 'MyLMSExample'
FEEDBACK_EMAIL_ADDRESS: '[email protected]'
Expand Down
3 changes: 2 additions & 1 deletion auth/src/main/java/org/openedx/auth/data/api/AuthApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.Response

interface AuthApi {

Expand All @@ -35,7 +36,7 @@ interface AuthApi {
@Field("password") password: String,
@Field("token_type") tokenType: String,
@Field("asymmetric_jwt") isAsymmetricJwt: Boolean = true,
): AuthResponse
): Response<AuthResponse>

@FormUrlEncoded
@POST(ApiConstants.URL_ACCESS_TOKEN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,39 @@ import org.openedx.core.config.Config
import org.openedx.core.data.storage.CorePreferences
import org.openedx.core.domain.model.RegistrationField
import org.openedx.core.system.EdxError
import android.util.Log

class AuthRepository(
private val config: Config,
private val api: AuthApi,
private val preferencesManager: CorePreferences,
) {

suspend fun login(
username: String,
password: String,
) {
api.getAccessToken(
ApiConstants.GRANT_TYPE_PASSWORD,
config.getOAuthClientId(),
username,
password,
config.getAccessTokenType(),
)
.mapToDomain()
.processAuthResponse()
suspend fun login(username: String, password: String): Result<AuthResponse> {
return try {
val response = api.getAccessToken(
grantType = "password",
clientId = "android",
username = username,
password = password,
tokenType = "JWT", // from your config (TOKEN_TYPE in JSON)
isAsymmetricJwt = true // default, you can omit if always true
)
if (response.isSuccessful) {
response.body()?.let {
Result.success(it.mapToDomain())
} ?: Result.failure(Exception("Empty response"))
} else {
val errorMsg = response.errorBody()?.string() ?: "Unknown error"
Result.failure(Exception(errorMsg))
}

} catch (e: Exception) {
Result.failure(e)
}
}


suspend fun socialLogin(token: String?, authType: AuthType) {
require(!token.isNullOrBlank()) { "Token is null" }
api.exchangeAccessToken(
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ buildscript {
}

plugins {
id 'com.android.application' version '8.5.2' apply false
id 'com.android.library' version '8.5.2' apply false
id 'com.android.application' version '8.12.2' apply false
id 'com.android.library' version '8.12.2' apply false
id 'org.jetbrains.kotlin.android' version "$kotlin_version" apply false
id 'com.google.gms.google-services' version '4.4.2' apply false
id "com.google.firebase.crashlytics" version "3.0.2" apply false
Expand Down
2 changes: 1 addition & 1 deletion default_config/dev/config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
API_HOST_URL: 'http://localhost:8000'
API_HOST_URL: 'https://4c1346f74eb5.ngrok-free.app'
APPLICATION_ID: 'org.openedx.app'
ENVIRONMENT_DISPLAY_NAME: 'Localhost'
URI_SCHEME: ''
Expand Down
2 changes: 1 addition & 1 deletion default_config/prod/config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
API_HOST_URL: 'http://localhost:8000'
API_HOST_URL: 'https://4c1346f74eb5.ngrok-free.app'
APPLICATION_ID: 'org.openedx.app'
ENVIRONMENT_DISPLAY_NAME: 'Localhost'
URI_SCHEME: ''
Expand Down
2 changes: 1 addition & 1 deletion default_config/stage/config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
API_HOST_URL: 'http://localhost:8000'
API_HOST_URL: 'https://4c1346f74eb5.ngrok-free.app'
APPLICATION_ID: 'org.openedx.app'
ENVIRONMENT_DISPLAY_NAME: 'Localhost'
URI_SCHEME: ''
Expand Down
12 changes: 12 additions & 0 deletions default_config/user_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
API_HOST_URL: "https://4c1346f74eb5.ngrok-free.app"
PLATFORM_NAME: "Soham's Local edX"
ENVIRONMENT_DISPLAY_NAME: "Local Dev"
OAUTH_CLIENT_ID: "android"
DISCOVERY:
TYPE: native
FIREBASE:
ENABLED: false
MICROSOFT:
ENABLED: false
FACEBOOK:
ENABLED: false
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class NativeDiscoveryViewModelTest {
every { resourceManager.getString(R.string.core_error_unknown_error) } returns somethingWrong
every { appNotifier.notifier } returns emptyFlow()
every { corePreferences.user } returns null
every { config.getApiHostURL() } returns "http://localhost:8000"
every { config.getApiHostURL() } returns "https://4c1346f74eb5.ngrok-free.app"
every { config.isPreLoginExperienceEnabled() } returns false
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri May 03 13:24:00 EEST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists