Skip to content

Commit

Permalink
Merge pull request #53 from Web3Auth/feat/mandatory-login-provider
Browse files Browse the repository at this point in the history
Make login provider mandatory
  • Loading branch information
chaitanyapotti authored Jan 31, 2023
2 parents 84ba841 + 604e152 commit 9b705a6
Show file tree
Hide file tree
Showing 5 changed files with 479 additions and 62 deletions.
16 changes: 16 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"eslint.workingDirectories": [
{
"directory": "example",
"changeProcessCWD": true
},
{
"directory": ".",
"changeProcessCWD": true
},
{
"directory": "example_general",
"changeProcessCWD": true
}
]
}
33 changes: 17 additions & 16 deletions example/App.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
import { StatusBar } from "expo-status-bar";
import { useState } from "react";
import { StyleSheet, Text, View, Button } from "react-native";
import Web3Auth, { LOGIN_PROVIDER, OPENLOGIN_NETWORK, State } from "@web3auth/react-native-sdk";
import { Buffer } from "buffer";
import Constants, { AppOwnership } from "expo-constants";
import * as Linking from "expo-linking";
import { StatusBar } from "expo-status-bar";
import * as WebBrowser from "expo-web-browser";
import { Buffer } from "buffer";
import { useState } from "react";
import { Button, StyleSheet, Text, View } from "react-native";

global.Buffer = global.Buffer || Buffer;

const scheme = "web3authexposample";

const resolvedRedirectUrl =
Constants.appOwnership == AppOwnership.Expo || Constants.appOwnership == AppOwnership.Guest
Constants.appOwnership === AppOwnership.Expo || Constants.appOwnership === AppOwnership.Guest
? Linking.createURL("web3auth", {})
: Linking.createURL("web3auth", { scheme: scheme });
: Linking.createURL("web3auth", { scheme });

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
});

export default function App() {
const [key, setKey] = useState("");
Expand All @@ -27,12 +36,13 @@ export default function App() {
network: OPENLOGIN_NETWORK.TESTNET,
});
const state = await web3auth.login({
loginProvider: LOGIN_PROVIDER.GOOGLE,
redirectUrl: resolvedRedirectUrl,
loginProvider: LOGIN_PROVIDER.GOOGLE,
});
setKey(state.privKey || "no key");
setUserInfo(state);
} catch (e) {
// eslint-disable-next-line no-console
console.error(e);
setErrorMsg(String(e));
}
Expand All @@ -48,12 +58,3 @@ export default function App() {
</View>
);
}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
});
Loading

0 comments on commit 9b705a6

Please sign in to comment.