-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Patch] Revoke OAuth tokens at sample start #239
Conversation
// Sign out of any portals which are already authenticated | ||
runBlocking { | ||
ArcGISEnvironment.authenticationManager.signOut() | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not recommended to use runBlocking
in production code. The alternative here is to launch a coroutine on the Main dispatcher, then tdo the sign out followed by displaying the app:
// Sign out of any portals which are already authenticated | |
runBlocking { | |
ArcGISEnvironment.authenticationManager.signOut() | |
} | |
lifecycleScope.launch(Dispatchers.Main) { | |
// Sign out of any portals which are already authenticated | |
ArcGISEnvironment.authenticationManager.signOut() | |
setContent { | |
SampleAppTheme { | |
AuthenticateWithOAuthApp() | |
} | |
} | |
} |
Same change would need to be made to Show Portal User Info & Create And Save Map samples.
import com.esri.arcgismaps.sample.authenticatewithoauth.components.MapViewModel | ||
import com.esri.arcgismaps.sample.authenticatewithoauth.screens.MainScreen | ||
import com.esri.arcgismaps.sample.sampleslib.theme.SampleAppTheme | ||
import kotlinx.coroutines.runBlocking | ||
|
||
class MainActivity : ComponentActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the API key also be nulled out here, same as you did in Create And Safe Map sample?
@@ -35,6 +37,11 @@ class MainActivity : ComponentActivity() { | |||
// required to access basemaps and other location services | |||
ArcGISEnvironment.apiKey = ApiKey.create(BuildConfig.API_KEY) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be setting an API key here, since the sample uses a named user?
\cc @shubham7109
This PR will be replaced with #244 to apply these changes on the SV level. There are some parceling issues to iron out currently, and once completed I would request a review from @01smito01 / @gunt0001 |
Closing as #244 should be done this release. Will draft a new PR for removing the existing workflow from Create & Save Map. |
Description
Change "Show portal user info" and "Authenticate with OAuth" to remove any cached authentication from
ArcGISEnvironment
. This makes them behave properly in the sample viewer even after a user has authenticated in another sampleLinks and Data
Sample Epic: #4755
What To Review
runBlocking
the best way to implement this?How to Test
Run the samples in the sample viewer. Do they present an authentication challenge after completing one in another sample?