Skip to content

Commit aa9d98b

Browse files
test: run examples for version 5.1.9-alpha.2
1 parent c9cd46c commit aa9d98b

20 files changed

Lines changed: 1414 additions & 1174 deletions

File tree

examples/guard-angular/normal/package-lock.json

Lines changed: 436 additions & 363 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/guard-angular/normal/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.0",
44
"scripts": {
55
"ng": "ng",
6-
"dev": "ng serve --port 3000",
6+
"dev": "ng serve --port 3003",
77
"build": "ng build",
88
"watch": "ng build --watch --configuration development",
99
"test": "ng test"
@@ -19,7 +19,7 @@
1919
"@angular/platform-browser": "^14.0.0",
2020
"@angular/platform-browser-dynamic": "^14.0.0",
2121
"@angular/router": "^14.0.0",
22-
"@authing/guard-angular": "^5.1.6-alpha.2",
22+
"@authing/guard-angular": "^5.1.9-alpha.2",
2323
"face-api.js": "^0.22.2",
2424
"rxjs": "~7.5.0",
2525
"tslib": "^2.3.0",

examples/guard-angular/normal/src/app/app.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ import * as facePlugin from 'face-api.js'
1515
BrowserModule,
1616
AppRoutingModule,
1717
GuardModule.forRoot({
18-
appId: 'AUTHING_APP_ID',
18+
appId: '6319f41de72e9e18a1bafba6',
1919

2020
// 如果你使用的是私有化部署的 Authing 服务,需要传入自定义 host,如:
2121
// host: 'https://my-authing-app.example.com',
2222

2323
// 默认情况下,会使用你在 Authing 控制台中配置的第一个回调地址为此次认证使用的回调地址。
2424
// 如果你配置了多个回调地址,也可以手动指定(此地址也需要加入到应用的「登录回调 URL」中):
25-
redirectUri: "YOUR_REDIRECT_URI",
25+
redirectUri: "https://aaaaaa1bbv.authing.cn",
2626

2727
isSSO: true,
2828
config: {

examples/guard-angular/normal/src/app/pages/embed/embed.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@
1919

2020
<button class="authing-button" (click)="refreshToken()">Refresh Token</button>
2121

22+
<button class="authing-button" (click)="getAccessTokenByIdToken()">Get Access Token By Id Token</button>
23+
2224
<div id="authing-guard-container"></div>
2325
</div>

examples/guard-angular/normal/src/app/pages/embed/embed.component.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@ export class EmbedComponent {
1515

1616
langCache = ''
1717

18+
userInfo: null | User = null
19+
1820
ngOnInit() {
1921
console.log('guard instance: ', this.guard.client)
2022

2123
// 使用 start 方法挂载 Guard 组件到你指定的 DOM 节点,登录成功后返回 userInfo
2224
this.guard.client.start('#authing-guard-container').then((userInfo: User) => {
2325
console.log(userInfo)
26+
this.userInfo = userInfo
2427
})
2528

2629
this.guard.client.on('load', (authClient: AuthenticationClient) => {
@@ -33,6 +36,7 @@ export class EmbedComponent {
3336

3437
this.guard.client.on('login', (userInfo: User) => {
3538
console.log('userInfo in login: ', userInfo)
39+
this.userInfo = userInfo
3640
})
3741
}
3842

@@ -72,4 +76,13 @@ export class EmbedComponent {
7276
this.langCache = event?.target?.value
7377
this.guard.client.changeLang(event?.target?.value)
7478
}
79+
80+
async getAccessTokenByIdToken () {
81+
const authenticationClient: AuthenticationClient = await this.guard.client.getAuthClient()
82+
const res = await authenticationClient.getAccessTokenByIdToken({
83+
redirectUri: 'https://www.baidu.com',
84+
idToken: this.userInfo!.token as string
85+
})
86+
console.log('getAccessTokenByIdToken: ', res)
87+
}
7588
}

examples/guard-react/normal/package-lock.json

Lines changed: 37 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/guard-react/normal/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"webpack-merge": "^4.2.1"
2525
},
2626
"dependencies": {
27-
"@authing/guard-react": "^5.1.9-alpha.0",
27+
"@authing/guard-react": "^5.1.9-alpha.2",
2828
"face-api.js": "^0.22.2",
2929
"react": "^16.13.1",
3030
"react-dom": "^16.13.1",

examples/guard-react/normal/src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import './App.css'
1313
export default function App() {
1414
return (
1515
<GuardProvider
16-
appId="6319f41de72e9e18a1bafba6"
16+
appId="AUTHING_APP_ID"
1717

1818
// 如果你使用的是私有化部署的 Authing 服务,需要传入自定义 host,如:
19-
host="https://aaaaaa1bbv.authing.cn"
19+
host="https://example.authing.cn"
2020

2121
// 默认情况下,会使用你在 Authing 控制台中配置的第一个回调地址为此次认证使用的回调地址。
2222
// 如果你配置了多个回调地址,也可以手动指定(此地址也需要加入到应用的「登录回调 URL」中):

examples/guard-react/normal/src/pages/Embed.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,11 @@ export default function Login() {
113113

114114
const getAccessTokenByIdToken = async () => {
115115
const authenticationClient: AuthenticationClient = await guard.getAuthClient()
116-
const refreshedToken: RefreshToken = await authenticationClient.getAccessTokenByIdToken({
117-
grantType: 'http://authing.cn/oidc/grant_type/authing_token',
116+
const res = await authenticationClient.getAccessTokenByIdToken({
118117
redirectUri: 'https://www.baidu.com',
119118
idToken: userInfo!.token as string
120119
})
121-
console.log('getAccessTokenByIdToken: ', refreshedToken)
120+
console.log('getAccessTokenByIdToken: ', res)
122121
}
123122

124123
return <div>

0 commit comments

Comments
 (0)