Skip to content

Commit

Permalink
fix(google-sign-in): fix google sign in option
Browse files Browse the repository at this point in the history
SUITEDEV-35599

Co-authored-by: megamegax <[email protected]>
Co-authored-by: kovacszsoltizsolt <[email protected]>
  • Loading branch information
3 people committed May 2, 2024
1 parent 8475b5b commit 0600e41
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/nightly_e2e_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ env:
SLACK_TITLE: Commit status
SLACK_USERNAME: Emarsys SDK - Android
SLACK_WEBHOOK: ${{ secrets.SLACK_MOBILE_TEAM_CI_CHANNEL_WEBHOOK }}
FIREBASE_WEB_SERVER_CLIENT_ID: ${{ secrets.FIREBASE_WEB_SERVER_CLIENT_ID }}

jobs:
Build:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/nightly_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ env:
SLACK_TITLE: Nightly build status
SLACK_USERNAME: Emarsys SDK - Android
SLACK_WEBHOOK: ${{ secrets.SLACK_MOBILE_TEAM_CI_CHANNEL_WEBHOOK }}
FIREBASE_WEB_SERVER_CLIENT_ID: ${{ secrets.FIREBASE_WEB_SERVER_CLIENT_ID }}

jobs:
Build:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/on_push_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ env:
SLACK_TITLE: Commit status
SLACK_USERNAME: Emarsys SDK - Android
SLACK_WEBHOOK: ${{ secrets.SLACK_MOBILE_TEAM_CI_CHANNEL_WEBHOOK }}
FIREBASE_WEB_SERVER_CLIENT_ID: ${{ secrets.FIREBASE_WEB_SERVER_CLIENT_ID }}

jobs:
Test:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release_sample_app_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ env:
SLACK_TITLE: Commit status
SLACK_USERNAME: Emarsys SDK - Android
SLACK_WEBHOOK: ${{ secrets.SLACK_MOBILE_TEAM_CI_CHANNEL_WEBHOOK }}
FIREBASE_WEB_SERVER_CLIENT_ID: ${{ secrets.FIREBASE_WEB_SERVER_CLIENT_ID }}

jobs:
ReleaseSampleApp:
Expand Down
10 changes: 10 additions & 0 deletions sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ android {
)
}\""
)
buildConfigField(
"String",
"FIREBASE_WEB_SERVER_CLIENT_ID",
"\"${
env.fetch(
"FIREBASE_WEB_SERVER_CLIENT_ID",
System.getenv("FIREBASE_WEB_SERVER_CLIENT_ID") ?: ""
)
}\""
)
}

buildFeatures {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class DashboardScreen(
} else {
Emarsys.setAuthenticatedContact(
viewModel.getTfContactFieldIdValue().toInt(),
account.email!!
account.idToken!!
) {
if (verifyLogin(it, context)) {
setupInfoSetContact(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ import android.app.Activity
import android.content.Context
import android.content.Intent
import androidx.activity.result.contract.ActivityResultContract
import com.emarsys.sample.BuildConfig
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.GoogleSignInClient
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
import com.google.android.gms.tasks.Task

class GoogleAuthResult : ActivityResultContract<Int, Task<GoogleSignInAccount>?>() {
override fun createIntent(context: Context, input: Int): Intent =
private companion object {
const val SERVER_CLIENT_ID = BuildConfig.FIREBASE_WEB_SERVER_CLIENT_ID
}

override fun createIntent(context: Context, input: Int): Intent =
getGoogleSignInClient(context).signInIntent.putExtra("input", input)

override fun parseResult(resultCode: Int, intent: Intent?): Task<GoogleSignInAccount>? {
Expand All @@ -24,6 +29,7 @@ class GoogleAuthResult : ActivityResultContract<Int, Task<GoogleSignInAccount>?>
private fun getGoogleSignInClient(context: Context): GoogleSignInClient {
val signInOptions = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestIdToken(SERVER_CLIENT_ID)
.build()

return GoogleSignIn.getClient(context, signInOptions)
Expand Down

0 comments on commit 0600e41

Please sign in to comment.