[fenix] Issue https://github.com/mozilla-mobile/fenix/issues/418: Basic Firefox Accounts integration
This patch integrates relevant a-c components, and updates the current Preferences UI to allow signing-in and displaying basic account information (email, displayName). Currently there's no Accounts UI, and so singing out or otherwise interacting with the account isn't possible.pull/600/head
parent
0898d23c69
commit
5767a3d756
@ -0,0 +1,32 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.components
|
||||
|
||||
import android.content.Context
|
||||
import mozilla.components.service.fxa.Config
|
||||
import mozilla.components.service.fxa.FxaAccountManager
|
||||
|
||||
/**
|
||||
* Component group for background services. These are the components that need to be accessed from within a
|
||||
* background worker.
|
||||
*/
|
||||
class BackgroundServices(
|
||||
context: Context
|
||||
) {
|
||||
companion object {
|
||||
const val CLIENT_ID = "a2270f727f45f648"
|
||||
const val REDIRECT_URL = "https://accounts.firefox.com/oauth/success/$CLIENT_ID"
|
||||
const val SUCCESS_PATH = "connect_another_device?showSuccessMessage=true"
|
||||
}
|
||||
|
||||
// This is slightly messy - here we need to know the union of all "scopes"
|
||||
// needed by components which rely on FxA integration. If this list
|
||||
// grows too far we probably want to find a way to determine the set
|
||||
// at runtime.
|
||||
private val scopes: Array<String> = arrayOf("profile", "https://identity.mozilla.com/apps/oldsync")
|
||||
private val config = Config.release(CLIENT_ID, REDIRECT_URL)
|
||||
|
||||
val accountManager = FxaAccountManager(context, config, scopes).also { it.init() }
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.components
|
||||
|
||||
import mozilla.components.feature.accounts.FirefoxAccountsAuthFeature
|
||||
import mozilla.components.feature.tabs.TabsUseCases
|
||||
import mozilla.components.service.fxa.FxaAccountManager
|
||||
|
||||
/**
|
||||
* Component group which encapsulates foreground-friendly services.
|
||||
*/
|
||||
class Services(
|
||||
private val accountManager: FxaAccountManager,
|
||||
private val tabsUseCases: TabsUseCases
|
||||
) {
|
||||
val accountsAuthFeature by lazy {
|
||||
FirefoxAccountsAuthFeature(
|
||||
accountManager,
|
||||
tabsUseCases,
|
||||
redirectUrl = BackgroundServices.REDIRECT_URL,
|
||||
successPath = BackgroundServices.SUCCESS_PATH
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue