Please provide the following:
- SDK Version: 43
- Platforms(Android/iOS/web/all): all
- Add the appropriate “Tag” based on what Expo library you have a question on.
I have copied the code from the example on authorizing a reddit app here Authentication - Expo Documentation.
For reference, here is my code
import React from 'react';
import { Linking } from 'react-native';
import * as WebBrowser from 'expo-web-browser';
import { makeRedirectUri, useAuthRequest } from 'expo-auth-session';
import { Button } from 'react-native-paper';
import { useAppDispatch } from '../../common/hooks/redux';
import { setAuthCode } from '../../common/state/authSlice';
WebBrowser.maybeCompleteAuthSession();
// Endpoint
const discovery = {
authorizationEndpoint: 'https://www.reddit.com/api/v1/authorize.compact',
tokenEndpoint: 'https://www.reddit.com/api/v1/access_token',
};
const LoginScreen = () => {
const dispatch = useAppDispatch();
const [request, response, promptAsync] = useAuthRequest(
{
clientId: 'CLIENT_ID',
scopes: ['identity'],
redirectUri: makeRedirectUri({
// For usage in bare and standalone
native: 'your.app://redirect',
}),
},
discovery
);
React.useEffect(() => {
if (response?.type === 'success') {
const { code } = response.params;
dispatch(setAuthCode(code));
}
}, [response]);
return (
<Button
disabled={!request}
onPress={() => {
promptAsync();
}}
>
Login
</Button>
);
};
export default LoginScreen;
However, when this link opens after pressing the login button, it simply takes me to a page that says ‘You broke reddit.’ without any further errors that might help me debug. I am getting no errors in the console running expo start, so I’m not sure where to go from here. Was the more customization I needed to do to that example code? The snack version of it isn’t building so I can’t verify if it’s just happening on my devices/emulators.