mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2026-03-10 18:55:03 +00:00
Set up initial Lambda sturucture with Cognito
Create demo Lambda/Gateway pair with Cognito integration
This commit is contained in:
11
Listify/Pipfile
Normal file
11
Listify/Pipfile
Normal file
@@ -0,0 +1,11 @@
|
||||
[[source]]
|
||||
name = "pypi"
|
||||
url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
|
||||
[dev-packages]
|
||||
|
||||
[packages]
|
||||
|
||||
[requires]
|
||||
python_version = "3.8"
|
||||
@@ -94,7 +94,7 @@ Parameters:
|
||||
|
||||
userPoolGroupList:
|
||||
Type: CommaDelimitedList
|
||||
|
||||
|
||||
serviceName:
|
||||
Type: String
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"identityPoolName": "listifyf4fad454_identitypool_f4fad454",
|
||||
"allowUnauthenticatedIdentities": false,
|
||||
"allowUnauthenticatedIdentities": true,
|
||||
"resourceNameTruncated": "listiff4fad454",
|
||||
"userPoolName": "listifyf4fad454_userpool_f4fad454",
|
||||
"autoVerifiedAttributes": [
|
||||
|
||||
@@ -6,5 +6,7 @@
|
||||
"dependsOn": [],
|
||||
"customAuth": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"function": {},
|
||||
"api": {}
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
package com.example.listify;
|
||||
|
||||
import android.util.Log;
|
||||
import com.amplifyframework.auth.AuthException;
|
||||
import com.amplifyframework.auth.AuthSession;
|
||||
import com.amplifyframework.auth.cognito.AWSCognitoAuthSession;
|
||||
import com.amplifyframework.auth.options.AuthSignUpOptions;
|
||||
import com.amplifyframework.auth.result.AuthSignInResult;
|
||||
import com.amplifyframework.auth.result.AuthSignUpResult;
|
||||
import com.amplifyframework.core.Amplify;
|
||||
|
||||
public class AuthManager {
|
||||
AuthSession authSession = null;
|
||||
AWSCognitoAuthSession authSession = null;
|
||||
AuthSignUpResult authSignUpResult = null;
|
||||
AuthSignInResult authSignInResult = null;
|
||||
AuthException authError = null;
|
||||
@@ -27,14 +27,21 @@ public class AuthManager {
|
||||
throwIfAuthError();
|
||||
}
|
||||
|
||||
public AuthSession getAuthSession() throws AuthException {
|
||||
fetchAuthSession();
|
||||
public AWSCognitoAuthSession getAuthSession() throws AuthException {
|
||||
if (authSession == null) {
|
||||
fetchAuthSession();
|
||||
}
|
||||
|
||||
return authSession;
|
||||
}
|
||||
|
||||
public String getUserToken() {
|
||||
return authSession.getUserPoolTokens().getValue().getIdToken();
|
||||
}
|
||||
|
||||
|
||||
public void setAuthSession(AuthSession toSet) {
|
||||
authSession = toSet;
|
||||
authSession = (AWSCognitoAuthSession) toSet;
|
||||
waiting = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
try {
|
||||
authManager.signIn("merzn@purdue.edu", "Password123");
|
||||
Log.i("Authentication", authManager.getAuthSession().toString());
|
||||
Log.i("Token", authManager.getAuthSession().getUserPoolTokens().getValue().getIdToken());
|
||||
} catch (AuthException e) {
|
||||
Log.i("Authentication", "Login failed. User probably needs to register. Exact error: " + e.getMessage());
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user