I'm trying to use FormidableLabs/react-native-app-auth
in my react native android app. I have created google oauth client id in google developer console as a web application. I have a problem adding correct redirect url in the console. As i have read the redirect url for android applications should look like something like this com.testapp.app:/oauth
but these type of urls cannot be added in the google developer console. So how should i add it ?
AndroidManifest.xml
<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="com.testchat.app" android:host="heybuddyapp/callback"/>
</intent-filter>
is the scheme correct or should it be changed ?
build.gradle
defaultConfig {
...
manifestPlaceholders = [
appAuthRedirectScheme: 'com.testchat.app:/heybuddyapp/callback'
]
}
config of react native app auth
const config = {
issuer: 'https://accounts.google.com',
clientId: 'ID.apps.googleusercontent.com',
redirectUrl: 'com.testchat.app:/heybuddyapp/callback',
scopes: [
'openid',
'profile'
],
};
How should be the redirect url in the above sections ? And how should it be on the google developer console ?
Any help would be appreciated !
For future readers.. I have figured out the answer. I was using web application in the google developer console create credentials section, but it should be Android instead. After adding the Signing-certificate fingerprint reference - react native sign apk Then you should add your package name as in the AndroidManifest.xml (example - com.testapp.app
) Then in the android\app\build.gradle
file add
defaultConfig {
...
manifestPlaceholders = [
appAuthRedirectScheme: 'com.testapp.app' //this line
]
}
And if you are usging FormidableLabs/react-native-app-auth
package, config should be like this
const config = {
issuer: 'https://accounts.google.com',
clientId: 'ID.apps.googleusercontent.com',
redirectUrl: 'com.testapp.app:/oauth2callback',
scopes: [
'openid',
'profile'
],
};
And that's it !