AwsInterceptor | AWS Gateway OkHttp Interceptor
kandi X-RAY | AwsInterceptor Summary
kandi X-RAY | AwsInterceptor Summary
AwsInterceptor
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of AwsInterceptor
AwsInterceptor Key Features
AwsInterceptor Examples and Code Snippets
Community Discussions
Trending Discussions on AwsInterceptor
QUESTION
I'm writing a simple Android app that currently offers the following features:
- Register/login with email and password, against an AWS Cognito back end
- Logout (against the same Cognito back end)
- Call a protected web API on AWS API Gateway
I'm building my own very simple login/logout UI, rather than using the AWS Cognito UI library:
Login screen (left); logged-in screen (right)
The web API should return 200 (and a body) when the user is logged in, and a 403 error when they are logged out. The server setup all appears to be correct, and an equivalent app on iOS is working as described.
The problem on Android is as follows:
- When I start the app, don't log in, and call the API: I get a 403 error (expected).
- When I log in and call the API again: I still get a 403 error (unexpected).
- When I close the app, swipe it from the recent apps list, and re-open it: I'm still logged in (expected)
- Now when I call the API: I get a 200 response (expected).
The same happens now if I log out: I still get a 200 response after logging out until I kill the app and restart it.
How can I get the API Gateway call to respect my current authentication state immediately, without recycling the app?
I wondered if the AWS API Gateway Android library might be to blame, so I've tried an alternative implementation using OkHttp but I get exactly the same result. I've based my Cognito code on the AmazonCognitoYourUserPools demo.
Here's the part of my build.gradle that imports the AWS libraries:
...ANSWER
Answered 2018-Apr-24 at 14:17The solution my colleague and I have arrived at is as follows:
LoginAfter login, you need to re-initialise the AWSMobileClient
before you call any API Gateway endpoints. Here's a snippet from my AuthenticationHandler
in LoginActivity.java
:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install AwsInterceptor
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page