Задать вопрос
@SomeDude1314

Проблема с Oauth yandex appwrite?

День добрый, я попытался интегрировать авторизацию через яндекс она работает но я не могу понять как мне исправить ошибку с "Приложение не установлено" и как сделать редирект назад в приложение? уже 2 дня не могу найти ответа,
gpt давал примеры использования в место ссылок appname://success и тд но это вообще вызывает ошибку 400

вот мой код

<activity
            android:name=".user.TestActivity"
            android:exported="true"
            android:label="@string/app_name"
            android:theme="@style/Theme.Irminsule">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data
                    android:scheme="https"
                    android:host="cloud.appwrite.io"
                    android:pathPrefix="/v1/account/sessions/oauth2/callback/yandex/67b693810011e520cf60" />
            </intent-filter>

        </activity>


class TestActivity : ComponentActivity() {
    override fun onNewIntent(intent: Intent) {
        super.onNewIntent(intent)
        intent.data?.let { uri ->
            if (uri.scheme == "https" && uri.host == "cloud.appwrite.io" && uri.path?.startsWith("/v1/account/sessions/oauth2/callback/yandex/67b693810011e520cf60") == true) {
                Toast.makeText(this, "Авторизация прошла успешно!", Toast.LENGTH_SHORT).show()

            }
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContent {
            YandexLoginButton(this)
        }
    }
}

@Composable
fun YandexLoginButton(activity: ComponentActivity) {
    val coroutineScope = rememberCoroutineScope()

    Button(
        onClick = {
            coroutineScope.launch {
                val client = Client(activity)
                    .setEndpoint("https://cloud.appwrite.io/v1")
                    .setProject("PROJECT_ID")

                val account = Account(client)
                account.createOAuth2Session(
                    activity = activity,
                    provider = OAuthProvider.YANDEX,
                    success = "https://cloud.appwrite.io/v1/account/sessions/oauth2/callback/yandex/67b693810011e520cf60",
                    failure = "https://cloud.appwrite.io/v1/account/sessions/oauth2/callback/yandex/67b693810011e520cf60"
                )
            }
        },
        colors = ButtonDefaults.buttonColors(containerColor = Color(0xFFFC3F1D))
    ) {
        Text(text = "Войти через Яндекс", color = Color.White)
    }
}

67bc1b9490eb5343159459.png
  • Вопрос задан
  • 14 просмотров
Подписаться 1 Простой Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы