diff --git a/react-native/Get access token b/react-native/Get access token new file mode 100644 index 00000000..57e01eb0 --- /dev/null +++ b/react-native/Get access token @@ -0,0 +1,23 @@ +const axios = require('axios'); +const base64 = require('base-64'); + +const clientId = 'YOUR_CLIENT_ID'; +const clientSecret = 'YOUR_CLIENT_SECRET'; + +const getToken = async () => { + try { + const response = await axios.post( + 'https://sandbox.interswitchng.com/passport/oauth/token', + 'grant_type=client_credentials', + { + headers: { + Authorization: `Basic ${base64.encode(`${clientId}:${clientSecret}`)}`, + 'Content-Type': 'application/x-www-form-urlencoded' + } + } + ); + return response.data.access_token; + } catch (error) { + console.error('Token error:', error.response?.data || error.message); + } +};