-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
44 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import { oauth2_authorize, oauth2_token, oauth2_userinfo } from "../src"; | ||
import { cas_login, cas_oauth2_authorize, cas_oauth2_token, cas_oauth2_userinfo } from "../src"; | ||
import { credentials } from "./_credentials"; | ||
|
||
void async function main () { | ||
const code = await oauth2_authorize(credentials); | ||
const { access_token } = await oauth2_token(code); | ||
const { email, name, sub } = await oauth2_userinfo(access_token); | ||
const cas_token = await cas_login(credentials.username, credentials.password); | ||
const code = await cas_oauth2_authorize(cas_token); | ||
const { access_token } = await cas_oauth2_token(code); | ||
const { email, name, sub } = await cas_oauth2_userinfo(access_token); | ||
|
||
console.log("Logged to", sub, "with email", email, "and name", name); | ||
}(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { credentials } from "./_credentials"; | ||
import { cas_login, cas_service, CAS_EXTERNAL_SERVICES } from "../src"; | ||
|
||
/** | ||
* In this example, we'll see how we can get a ticket for an external service. | ||
* An external service is like a Moodle instance, a calendar, or a forum. | ||
* | ||
* We'll use the CAS to get those tickets. | ||
*/ | ||
void async function main () { | ||
// 1. get an authenticated token from the CAS. | ||
const cas_token = await cas_login(credentials.username, credentials.password); | ||
|
||
// 2. let's get a ticket for any service inside "CAS_EXTERNAL_SERVICES" constant. | ||
const iut_moodle_ticket = await cas_service(cas_token, CAS_EXTERNAL_SERVICES.IUT_COMMUNITY_MOODLE); | ||
console.log(iut_moodle_ticket); | ||
}(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import { get_moodle_courses, login_check, oauth2_authorize, oauth2_token } from "../src"; | ||
import { cas_login, get_moodle_courses, login_check, cas_oauth2_authorize, cas_oauth2_token } from "../src"; | ||
import { credentials } from "./_credentials"; | ||
|
||
void async function main () { | ||
const code = await oauth2_authorize(credentials); | ||
const { access_token } = await oauth2_token(code); | ||
const cas_token = await cas_login(credentials.username, credentials.password); | ||
const code = await cas_oauth2_authorize(cas_token); | ||
const { access_token } = await cas_oauth2_token(code); | ||
const { token } = await login_check(access_token); | ||
|
||
// Get Moodle courses from Biome API. | ||
const courses = await get_moodle_courses(token, true); | ||
console.log(courses); | ||
}(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters