Last major update: 25.08.2020
- Что такое авторизация/аутентификация
- Где хранить токены
- Как ставить куки ?
- Процесс логина
- Процесс рефреш токенов
- Кража токенов/Механизм контроля токенов
| import kotlinx.coroutines.FlowPreview | |
| import kotlinx.coroutines.Job | |
| import kotlinx.coroutines.cancelAndJoin | |
| import kotlinx.coroutines.coroutineScope | |
| import kotlinx.coroutines.flow.Flow | |
| import kotlinx.coroutines.flow.collect | |
| import kotlinx.coroutines.flow.flow | |
| import kotlinx.coroutines.launch | |
| /** |
| import com.android.tools.lint.client.api.UElementHandler | |
| import com.android.tools.lint.detector.api.* | |
| import org.jetbrains.uast.UElement | |
| import org.jetbrains.uast.UPostfixExpression | |
| class NonNullAssertionDetector : Detector(), Detector.UastScanner { | |
| override fun getApplicableUastTypes(): List<Class<out UElement>>? { | |
| return listOf(UPostfixExpression::class.java) | |
| } |
| /** | |
| * Authenticator that attempts to refresh the client's access token. | |
| * In the event that a refresh fails and a new token can't be issued an error | |
| * is delivered to the caller. This authenticator blocks all requests while a token | |
| * refresh is being performed. In-flight requests that fail with a 401 are | |
| * automatically retried. | |
| */ | |
| class AccessTokenAuthenticator( | |
| private val tokenProvider: AccessTokenProvider | |
| ) : Authenticator { |
| package com.abdelmeged.ahmed.roundedlayout; | |
| import android.support.v7.app.AppCompatActivity; | |
| import android.os.Bundle; | |
| import android.widget.ImageView; | |
| import com.bumptech.glide.load.engine.DiskCacheStrategy; | |
| import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions; | |
| public class MainActivity extends AppCompatActivity { |
| sudo add-apt-repository ppa:openjdk-r/ppa | |
| sudo apt-get update | |
| sudo apt-get install openjdk-7-jre | |
| # install openjdk | |
| sudo apt-get install openjdk-7-jdk | |
| # download android sdk | |
| wget http://dl.google.com/android/android-sdk_r24.2-linux.tgz |
| import asyncio | |
| from aiohttp import web | |
| import subprocess | |
| async def uptime_handler(request): | |
| # http://HOST:PORT/?interval=90 | |
| interval = int(request.GET.get('interval', 1)) | |
| # Without the Content-Type, most (all?) browsers will not render |
| import com.squareup.okhttp.Headers; | |
| import com.squareup.okhttp.MediaType; | |
| import com.squareup.okhttp.OkHttpClient; | |
| import com.squareup.okhttp.RequestBody; | |
| import com.squareup.okhttp.Response; | |
| import com.squareup.okhttp.ResponseBody; | |
| import java.io.IOException; | |
| import java.io.InputStream; | |
| import java.util.ArrayList; |
| public class AccountAuthenticator extends AbstractAccountAuthenticator { | |
| private final Context context; | |
| @Inject @ClientId String clientId; | |
| @Inject @ClientSecret String clientSecret; | |
| @Inject ApiService apiService; | |
| public AccountAuthenticator(Context context) { | |
| super(context); |
| NOTE: Easier way is the X86 way, described on https://www.genymotion.com/help/desktop/faq/#google-play-services | |
| Download the following ZIPs: | |
| ARM Translation Installer v1.1 (http://www.mirrorcreator.com/files/0ZIO8PME/Genymotion-ARM-Translation_v1.1.zip_links) | |
| Download the correct GApps for your Android version: | |
| Google Apps for Android 6.0 (https://www.androidfilehost.com/?fid=24052804347835438 - benzo-gapps-M-20151011-signed-chroma-r3.zip) | |
| Google Apps for Android 5.1 (https://www.androidfilehost.com/?fid=96042739161891406 - gapps-L-4-21-15.zip) | |
| Google Apps for Android 5.0 (https://www.androidfilehost.com/?fid=95784891001614559 - gapps-lp-20141109-signed.zip) |