Documentation: https://api.stackexchange.com/docs/authentication
Table of Contents
- 1 Create an app on stackapps
- 2 On successful app creation, you will get details
- 3 In SessionUtil file, add relevant details
- 4 Create secrets.properties in the root folder and add "key"
- 5 In AndroidManifest.xml, add host and scheme
- 6 Run the app and click on login button
- 7 Login to stackoverflow and then approve the app
- 8 You will be redirected to app upon clicking "approve" on step 7
- 9 Now on clicking
update
button in app, you will see the response from server in the Android Studio logcat. - 10 Documentation
url
https://stackapps.com/apps/oauth/register
example
example
example
STACK_EXCHANGE_KEY="YOUR_KEY_HERE"
Remember to add "key" and not secret.
example
Notice the resemblance in host
and scheme
here and the redirect_uri
in step 3. They should match.
example
Click on the login button in our app. On clicking login button, a browser will open and there you would need to login to stackoverflow.
example
example
Notice, the login
button is hidden and logout
button is shown now.
example
9 Now on clicking update
button in app, you will see the response from server in the Android Studio logcat.
Open Android Studio logcat and notice the response on clicking "update" button.
The update
button will send request to this endpoint in StackExchangeApiService.kt
@GET("/me?order=desc&sort=reputation&site=stackoverflow")
suspend fun getMyReputation(): String
The Documentation for above endpoint is here: https://api.stackexchange.com/docs/me
You can modify endpoints and do whatever at this point.
example
Find more Documentation, API endpoints here: https://api.stackexchange.com/docs/
example