Код: Выделить всё
import React, { useState, useEffect } from 'react';
import { View, ActivityIndicator, Platform, Button } from 'react-native';
import { WebView } from 'react-native-webview';
import * as WebBrowser from 'expo-web-browser';
import * as AuthSession from 'expo-auth-session';
import * as Linking from "expo-linking"
export default function OAuthLoginScreen({ route, navigation }) {
const [syncRunning, setSyncRunning] = useState(false);
const {
serverUrl,
authUrl,
tokenUrl,
tmpRedirectUri,
clientId,
scopes,
handleAuth
} = route.params;
const discovery = {
authorizationEndpoint: authUrl,
tokenEndpoint: tokenUrl
};
if(tmpRedirectUri === undefined || tmpRedirectUri === null){
redirectUri = AuthSession.makeRedirectUri({
scheme: 'myapp',
});
} else {
redirectUri = tmpRedirectUri;
}
const options = {
clientId: clientId,
redirectUri: redirectUri,
scopes: scopes
};
const [request, response, promptAsync] = AuthSession.useAuthRequest(
options,
discovery
);
if(request && !syncRunning){
setSyncRunning(true)
promptAsync()
}
useEffect(() => {
if (response?.type === 'success') {
const { code } = response.params;
handleAuth(serverUrl, result.url, navigation);
}
}, [response]);
return (
);
}
Когда тот же код используется с потоком входа в систему oauth в Instagram, он работает так же, как так и должно быть.
Подробнее здесь: https://stackoverflow.com/questions/793 ... lfed-login