Make the server URL configurable, used shared keys for signing
This commit is contained in:
@ -13,8 +13,8 @@ android {
|
||||
applicationId "app.omnivore.omnivore"
|
||||
minSdk 23
|
||||
targetSdk 32
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
versionCode 2
|
||||
versionName "0.0.2"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables {
|
||||
@ -22,9 +22,30 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
signingConfigs{
|
||||
release{
|
||||
keyAlias 'key0'
|
||||
storeFile file('external/omnivore-prod.keystore')
|
||||
storePassword 'omnivore'
|
||||
}
|
||||
debug{
|
||||
storePassword 'android'
|
||||
keyAlias 'androiddebugkey'
|
||||
storeFile file('external/omnivore-demo.keystore')
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug{
|
||||
signingConfig signingConfigs.debug
|
||||
buildConfigField("String", "OMNIVORE_API_URL", "\"https://api-demo.omnivore.app\"")
|
||||
buildConfigField("String", "OMNIVORE_GAUTH_SERVER_CLIENT_ID", "\"267918240109-eu2ar09unac3lqqigluknhk7t0021b54.apps.googleusercontent.com\"")
|
||||
}
|
||||
release {
|
||||
minifyEnabled false
|
||||
signingConfig signingConfigs.release
|
||||
buildConfigField("String", "OMNIVORE_API_URL", "\"https://api-prod.omnivore.app\"")
|
||||
buildConfigField("String", "OMNIVORE_GAUTH_SERVER_CLIENT_ID", "\"687911924401-lq8j1e97n0sv3khhb8g8n368lk4dqkbp.apps.googleusercontent.com\"")
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package app.omnivore.omnivore
|
||||
|
||||
object Constants {
|
||||
const val demoProdURL = "https://api-demo.omnivore.app"
|
||||
const val apiURL = BuildConfig.OMNIVORE_API_URL
|
||||
const val dataStoreName = "omnivore-datastore"
|
||||
}
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ interface AuthProviderLoginSubmit {
|
||||
|
||||
object RetrofitHelper {
|
||||
fun getInstance(): Retrofit {
|
||||
return Retrofit.Builder().baseUrl(Constants.demoProdURL)
|
||||
return Retrofit.Builder().baseUrl(Constants.apiURL)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.build()
|
||||
}
|
||||
|
||||
@ -1,30 +1,27 @@
|
||||
package app.omnivore.omnivore.ui.auth
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.ContentValues
|
||||
import android.util.Log
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.ActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import app.omnivore.omnivore.BuildConfig
|
||||
import app.omnivore.omnivore.R
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignIn
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignInAccount
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
|
||||
import com.google.android.gms.common.api.ApiException
|
||||
import com.google.android.gms.tasks.OnCompleteListener
|
||||
import com.google.android.gms.tasks.Task
|
||||
|
||||
@Composable
|
||||
fun GoogleAuthButton(viewModel: LoginViewModel) {
|
||||
val context = LocalContext.current
|
||||
|
||||
|
||||
val signInOptions = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
|
||||
.requestIdToken(stringResource(R.string.gcp_id))
|
||||
// .requestServerAuthCode(stringResource(R.string.gcp_id), true)
|
||||
.requestIdToken(BuildConfig.OMNIVORE_GAUTH_SERVER_CLIENT_ID)
|
||||
.requestEmail()
|
||||
.build()
|
||||
|
||||
val startForResult =
|
||||
|
||||
@ -7,10 +7,8 @@ import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.lifecycle.*
|
||||
import app.omnivore.omnivore.*
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignIn
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignInAccount
|
||||
import com.google.android.gms.common.api.ApiException
|
||||
import com.google.android.gms.tasks.OnCompleteListener
|
||||
import com.google.android.gms.tasks.Task
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
@ -91,10 +89,10 @@ class LoginViewModel @Inject constructor(
|
||||
Log.d(ContentValues.TAG, "granted Scopes?: ${result.grantedScopes}")
|
||||
val googleIdToken = result.idToken
|
||||
Log.d(ContentValues.TAG, "Google id token?: $googleIdToken")
|
||||
// TODO: submit id token to backend
|
||||
// If token is missing then set the error message
|
||||
|
||||
// If token is missing then set the error message
|
||||
if (googleIdToken == null) {
|
||||
errorMessage = "No authentication token found."
|
||||
return
|
||||
}
|
||||
|
||||
@ -113,7 +111,7 @@ class LoginViewModel @Inject constructor(
|
||||
if (result.body()?.authToken != null) {
|
||||
datastoreRepo.putString(DatastoreKeys.omnivoreAuthToken, result.body()?.authToken!!)
|
||||
} else {
|
||||
errorMessage = "Something went wrong. Please check your email/password and try again"
|
||||
errorMessage = "Something went wrong. Please check your credentials and try again"
|
||||
}
|
||||
|
||||
if (result.body()?.authCookieString != null) {
|
||||
|
||||
@ -47,7 +47,7 @@ class SaveViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
val apolloClient = ApolloClient.Builder()
|
||||
.serverUrl("${Constants.demoProdURL}/api/graphql")
|
||||
.serverUrl("${Constants.apiURL}/api/graphql")
|
||||
.addHttpHeader("Authorization", value = apiKey)
|
||||
.build()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user