forked from melod1n/fast-messenger
Retrieving sensitive data from local.properties
This commit is contained in:
@@ -2,6 +2,7 @@ package com.meloda.fast.api
|
||||
|
||||
import android.util.Log
|
||||
import com.meloda.fast.BuildConfig
|
||||
import com.meloda.fast.UserConfig
|
||||
import com.meloda.fast.api.util.VKUtil
|
||||
import java.net.URLEncoder
|
||||
|
||||
@@ -9,62 +10,50 @@ object VKAuth {
|
||||
|
||||
private const val TAG = "VKM.VKAuth"
|
||||
|
||||
const val settings =
|
||||
"notify," +
|
||||
"friends," +
|
||||
"photos," +
|
||||
"audio," +
|
||||
"video," +
|
||||
"docs," +
|
||||
"status," +
|
||||
"notes," +
|
||||
"pages," +
|
||||
"wall," +
|
||||
"groups," +
|
||||
"messages," +
|
||||
"offline," +
|
||||
"notifications"
|
||||
private const val settings = "notify," +
|
||||
"friends," +
|
||||
"photos," +
|
||||
"audio," +
|
||||
"video," +
|
||||
"docs," +
|
||||
"status," +
|
||||
"notes," +
|
||||
"pages," +
|
||||
"wall," +
|
||||
"groups," +
|
||||
"messages," +
|
||||
"offline," +
|
||||
"notifications"
|
||||
|
||||
const val redirectUrl = "https://oauth.vk.com/blank.html"
|
||||
private const val redirectUrl = "https://oauth.vk.com/blank.html"
|
||||
|
||||
fun getDirectAuthUrl(
|
||||
login: String,
|
||||
password: String,
|
||||
captchaSid: String? = null,
|
||||
captchaKey: String? = null
|
||||
): String {
|
||||
return "https://oauth.vk.com/token?grant_type=password&" +
|
||||
"client_id=${VKConstants.VK_APP_ID}&" +
|
||||
"scope=$settings&" +
|
||||
"client_secret=${VKConstants.VK_APP_SECRET}&" +
|
||||
"username=$login&" +
|
||||
"password=$password" +
|
||||
(if (captchaSid == null || captchaKey == null) "" else "&captcha_sid=$captchaSid&captcha_key=$captchaKey") +
|
||||
"&v=${VKApi.API_VERSION}"
|
||||
// return "https://oauth.vk.com/token?grant_type=password&" +
|
||||
// "client_id=2274003&" +
|
||||
// "scope=notify,friends,photos,audio,video,docs,notes,pages,status,offers,questions,wall,groups,messages,email,notifications,stats,ads,market,offline&" +
|
||||
// "client_secret=hHbZxrka2uZ6jB1inYsH&" +
|
||||
// "username=$login&" +
|
||||
// "password=$password" +
|
||||
// (if (captcha.isEmpty()) "" else "&$captcha") +
|
||||
// "&v=${VKApi.API_VERSION}"
|
||||
}
|
||||
) = "https://oauth.vk.com/token?grant_type=password&" +
|
||||
"client_id=${VKConstants.VK_APP_ID}&" +
|
||||
"scope=$settings&" +
|
||||
"client_secret=${BuildConfig.vkSecret}&" +
|
||||
"username=$login&" +
|
||||
"password=$password" +
|
||||
(if (captchaSid == null || captchaKey == null) "" else "&captcha_sid=$captchaSid&captcha_key=$captchaKey") +
|
||||
"&v=${URLEncoder.encode(VKApi.API_VERSION, "utf-8")}"
|
||||
|
||||
fun getUrl(api_id: String, settings: String): String {
|
||||
return "https://oauth.vk.com/authorize?" +
|
||||
"client_id=$api_id&" +
|
||||
"display=mobile&" +
|
||||
"scope=$settings&" +
|
||||
"redirect_uri=${
|
||||
URLEncoder.encode(
|
||||
redirectUrl,
|
||||
"utf-8"
|
||||
)
|
||||
}&" +
|
||||
"response_type=token&" +
|
||||
"v=${URLEncoder.encode(VKApi.API_VERSION, "utf-8")}"
|
||||
}
|
||||
|
||||
fun getOAuthUrl(settings: String) = "https://oauth.vk.com/authorize?" +
|
||||
"client_id=${UserConfig.FAST_APP_ID}&" +
|
||||
"display=mobile&" +
|
||||
"scope=$settings&" +
|
||||
"redirect_uri=${
|
||||
URLEncoder.encode(
|
||||
redirectUrl,
|
||||
"utf-8"
|
||||
)
|
||||
}&" +
|
||||
"response_type=token&" +
|
||||
"v=${URLEncoder.encode(VKApi.API_VERSION, "utf-8")}"
|
||||
|
||||
fun parseRedirectUrl(url: String): Pair<String, Int> {
|
||||
val accessToken = VKUtil.extractPattern(url, "access_token=(.*?)&") ?: ""
|
||||
|
||||
Reference in New Issue
Block a user