Skip to content

Instantly share code, notes, and snippets.

View PaulTR's full-sized avatar

Paul Ruiz PaulTR

  • Google
  • Boulder, Colorado, USA
View GitHub Profile
firebase_auth: ^0.14.0+5
firebase_dynamic_links: ^0.5.1
@override
void dispose() {
_emailController.dispose();
_passwordController.dispose();
super.dispose();
}
void signInWithPhoneNumber() async {}
void _register() async {
final FirebaseUser user = (await
_auth.createUserWithEmailAndPassword(
email: _emailController.text,
password: _passwordController.text,
)
).user;
if (user != null) {
setState(() {
_success = true;
val builder = AuthorizationRequest.Builder(
authServiceConfig,
Constants.CLIENT_ID,
ResponseTypeValues.CODE,
Uri.parse(Constants.URL_AUTH_REDIRECT))
.setCodeVerifier(codeVerifier,
codeChallenge,
Constants.CODE_VERIFIER_CHALLENGE_METHOD)
builder.setScopes(Constants.SCOPE_PROFILE,
fun signOutWithoutRedirect() {
val client = OkHttpClient()
val request = Request.Builder()
.url(Constants.URL_LOGOUT + authState.idToken)
.build()
try {
client.newCall(request).execute()
} catch (e: IOException) { }
}
private fun signOut() {
try {
val endSessionRequest = EndSessionRequest.Builder(authServiceConfig)
.setPostLogoutRedirectUri(Uri.parse(Constants.URL_LOGOUT_REDIRECT))
.setIdTokenHint(authState.accessToken)
.build()
val intent = authorizationService.getEndSessionRequestIntent(endSessionRequest)
launchIntent(intent)
{
"kind": "drive#fileList",
"etag": "\"7rZMux5cSmcgs0RqY3HlcLd9n7U\"",
"selfLink": "https:\/\/www.googleapis.com\/drive\/v2\/files",
"incompleteSearch": false,
"items": [{
"kind": "drive#file",
"id": "1CpwK5Fq6YhsSMsKm_4IGBHTe52tuJfsf",
"etag": "\"MTYzNjMwNjk4MjAwMA\"",
"selfLink": "https:\/\/www.googleapis.com\/drive\/v2\/files\/1CpwK5Fq6YhsSMsKm_4IGBHTe52tuJfsf",
fun makeApiCall() {
authState.performActionWithFreshTokens(authorizationService,
object: AuthState.AuthStateAction {
override fun execute(accessToken: String?, idToken: String?, ex: AuthorizationException?) {
GlobalScope.launch {
async(Dispatchers.IO) {
val client = OkHttpClient()
val request = Request.Builder()
.url(Constants.URL_API_CALL)
.addHeader("Authorization", "Bearer " + authState.accessToken)
class Constants {
companion object {
val SHARED_PREFERENCES_NAME = "AUTH_STATE_PREFERENCE"
val AUTH_STATE = "AUTH_STATE"
val SCOPE_PROFILE = "profile"
val SCOPE_EMAIL = "email"
val SCOPE_OPENID = "openid"
val SCOPE_DRIVE = "https://www.googleapis.com/auth/drive"