This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
firebase_auth: ^0.14.0+5 | |
firebase_dynamic_links: ^0.5.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@override | |
void dispose() { | |
_emailController.dispose(); | |
_passwordController.dispose(); | |
super.dispose(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void signInWithPhoneNumber() async {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void _register() async { | |
final FirebaseUser user = (await | |
_auth.createUserWithEmailAndPassword( | |
email: _emailController.text, | |
password: _passwordController.text, | |
) | |
).user; | |
if (user != null) { | |
setState(() { | |
_success = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun signOutWithoutRedirect() { | |
val client = OkHttpClient() | |
val request = Request.Builder() | |
.url(Constants.URL_LOGOUT + authState.idToken) | |
.build() | |
try { | |
client.newCall(request).execute() | |
} catch (e: IOException) { } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
NewerOlder