- create app
npx create-expo-app StickerSmash
- run app
cd StickerSmash
npx expo start
- navigation
- authentication
- Reach Hooks
- useState
- useEffect
- useContext
- useMemo
- context & Redux
- https calls
- other UI stuff
Get Oauth2Token use axios
import base64 from "react-native-base64";
import axios from "axios";
const getToken = async () => {
try {
const username = " ";
const password = " ";
const authHeader = "Basic " + base64.encode(${username}:${password}
);
const response = await axios.request({
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Authorization: authHeader,
},
url: "ords/dev_apex/oauth/token",
method: "post",
baseURL: "https://apex.chaoyu.nl/",
data: "grant_type=client_credentials",
});
const accessToken = response.data.access_token;
return accessToken;
} catch (error) {
console.error("Failed to obtain access token:", error);
throw error;
}
};
// Usage example
getToken()
.then((accessToken) => {
console.log("Access token:", accessToken);
// Use the access token for authenticated requests
})
.catch((error) => {
console.error("Failed to obtain access token:", error);
});
get Oauth2 token with fetch
import base64 from "react-native-base64";
const username = " ";
const password = " ";
const authHeader = "Basic " + base64.encode(${username}:${password}
);
fetch("https://apex.chaoyu.nl/ords/dev_apex/oauth/token", {
method: "POST",
body: "grant_type=client_credentials",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Authorization: authHeader,
},
})
.then(function (resp) {
// Return the response as JSON
return resp.json();
})
.then(function (data) {
// Log the API data
console.log("token", data);
})
.catch(function (err) {
// Log any errors
console.log("something went wrong", err);
});