FxaServer.kt 1.06 KB
Newer Older
isabelrios's avatar
isabelrios committed
1
2
3
/* 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/. */
Isabel Rios's avatar
Isabel Rios committed
4
5
6
7
package org.mozilla.fenix.components

import android.content.Context
import mozilla.components.service.fxa.ServerConfig
Edouard Oger's avatar
Edouard Oger committed
8
import mozilla.components.service.fxa.ServerConfig.Server
9
import org.mozilla.fenix.ext.settings
Isabel Rios's avatar
Isabel Rios committed
10

isabelrios's avatar
isabelrios committed
11
12
13
14
/**
 * Utility to configure Firefox Account servers.
 */

Isabel Rios's avatar
Isabel Rios committed
15
object FxaServer {
16
    private const val CLIENT_ID = "a2270f727f45f648"
Isabel Rios's avatar
Isabel Rios committed
17

18
    fun redirectUrl() = "urn:ietf:wg:oauth:2.0:oob:oauth-redirect-webchannel"
Isabel Rios's avatar
Isabel Rios committed
19
20

    fun config(context: Context): ServerConfig {
21
22
23
        val serverOverride = context.settings().overrideFxAServer
        val tokenServerOverride = context.settings().overrideSyncTokenServer.ifEmpty { null }
        if (serverOverride.isEmpty()) {
24
            return ServerConfig(Server.RELEASE, CLIENT_ID, redirectUrl(), tokenServerOverride)
25
        }
26
        return ServerConfig(serverOverride, CLIENT_ID, redirectUrl(), tokenServerOverride)
Isabel Rios's avatar
Isabel Rios committed
27
28
    }
}