-
Notifications
You must be signed in to change notification settings - Fork 0
Create Organization
Danny Hinshaw edited this page Dec 20, 2018
·
16 revisions
To create an organization you can use the /createOrganization
https endpoint.
// Authenticate as admin
const authRef = firebase.auth();
const userCred: UserCredential = await authRef.signInWithEmailAndPassword("[email protected]", "your-password");
const tokenID: string = await userCred.user.getIdToken();
// Users use the passcode to join the organization while setting up.
const testOrg = {
id: "SOME_CUSTOM_ORG_ID", // optional
logoUrl: 'https://photos.com/example', // optional.
name: 'Your New Organization', // required.
passcode: '<PASSCODE>' // required.
};
// Example request data
const requestObj = {
method: 'post',
body: JSON.stringify({ organization: testOrg }),
headers: {
'Authorization': `Bearer ${tokenID}`,
'Content-Type': 'application/json'
}
};
// URL For triggering http cloud functions
const apiBaseURL = "https://us-central1-mrg-production-8813d.cloudfunctions.net";
// Call the https endpoint
fetch(apiBaseURL.concat('/createOrganization'), requestObj)
.then((response) => console.log(response))
.catch((err: FirebaseError) => console.log(err));
// response ex. { id: "SdfsLS234jsdo3Sl30" }