Code: Select all
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 (
);
}
Stimmt es, dass ein HTTPS-Entwicklungsserver benötigt wird? Wenn ja, wie kann dies mit dem Metro-Bundler erreicht werden? Das Flag --https öffnet keine https-Sitzung. Ich möchte nicht zum Webpack zurückkehren, da es veraltet zu sein scheint. Ich habe es auch mit ǹgrok versucht, das https ermöglicht, aber auch das hat nicht funktioniert.
Wenn derselbe Code mit dem oauth-Anmeldefluss von Instagram verwendet wird, es funktioniert genau wie es sollte.