@@ -14,10 +14,10 @@ import (
1414
1515var authenticationClient * AuthenticationClient
1616var options = AuthenticationClientOptions {
17- AppId : "635143ae10d1c1b9afb54c39 " ,
18- AppSecret : "441d87d04bc22a0ac3fc5d7c0736278a " ,
19- AppHost : "http://localhost:3000 " ,
20- RedirectUri : "http://localhost:3003/callback " ,
17+ AppId : "" ,
18+ AppSecret : "" ,
19+ AppHost : "" ,
20+ RedirectUri : "http://localhost:8989 " ,
2121 InsecureSkipVerify : true ,
2222}
2323
@@ -65,7 +65,7 @@ func TestAuthUrl(t *testing.T) {
6565 Scope : "offline_access " + constant .DefaultScope ,
6666 })
6767 if err != nil {
68- t . Fatalf ( "构建授权url失败 %v" , err )
68+ panic ( err )
6969 return
7070 }
7171 println (result .Url )
@@ -111,38 +111,32 @@ func TestAuthUrl(t *testing.T) {
111111}
112112
113113func TestCode (t * testing.T ) {
114- tokenResponse , err := authenticationClient .GetAccessTokenByCode ("g1FZq2O8y3NzHvn3YwtTW7dau6lJD9Icq2ZTUR88d_a " )
114+ tokenResponse , err := authenticationClient .GetAccessTokenByCode ("BP7D0_o3Ya0TudEP3VolHVVywFDo_e3DFm-19koxQwy " )
115115 if err != nil {
116116 t .Fatalf ("code校验失败, %v" , err )
117117 return
118118 }
119119 fmt .Println (tokenResponse )
120120}
121121
122- func TestAccessToken (t * testing.T ) {
123- accessToken := `eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6I` +
124- `jROVS13OVZIcmVjU1BuT20zNzJubVF4V0ROV1hQbUQxbDdBckNseXhyVTAifQ.eyJ` +
125- `qdGkiOiJWeFdMRVJPY0FjSy0xR240Y0M3UGciLCJzdWIiOiI2MjkwNzU3ODliNDI0` +
126- `M2E1MGY2YzA0NTYiLCJpYXQiOjE2NTUyOTgxNzMsImV4cCI6MTY1NjUwNzc3Mywic` +
127- `2NvcGUiOiJvcGVuaWQgcHJvZmlsZSIsImlzcyI6Imh0dHBzOi8vbG9jYWx0ZXN0Ln` +
128- `Rlc3QyLmF1dGhpbmctaW5jLmNvL29pZGMiLCJhdWQiOiI2MmE4NTcwYTg1ODU5ZTI` +
129- `zOTBlZjM4OGYifQ.c64QBODEI_u1KQJaTi_00kz-zquXBwndwvKSRRc2N0LQBX9Ki` +
130- `mObyLBLEodkdZH61k-JVtI1IFlyupYB1QxejyxpfsbKMCokJ7JaM4J9l1I4Sre9RZ` +
131- `5CFrP3I03p0eEGiPSfLx3zBswfTz__b9ClnxyAGy3vqj69j3BZxK139ocnG39LHqg` +
132- `svZ5thY8w4iwFqZE3lZwKNPRdbaRnC5YyP6Y9M8xP9sQNiRTNxNGZPazCsj1RZWhK` +
133- `VP8a71QyTydSPccIi6s4-GzusO5iKC2bPEGtjwYaWlIK_C-cJtGhXwoYppbUP5sQV` +
134- `tVUPTVtbua_KYomBjsVIoGaeadV-cg1TA`
135- charim , err := authenticationClient .IntrospectAccessTokenOffline (accessToken )
136- if err != nil {
137- t .Fatalf ("access token 校验失败, %v" , err )
138- return
139- }
140- fmt .Println (charim )
141- user , err1 := authenticationClient .GetUserInfo (accessToken )
142- if err1 != nil {
143- t .Fatalf ("获取用户信息失败,%v" , err1 )
144- }
145- fmt .Println (user )
122+ func TestIntrospectToken (t * testing.T ) {
123+ code := "e1I4h2L-9-BaaL87YKtZgjKxsUHppaPW2jsLCsEokuL"
124+ tokenResponse , _ := authenticationClient .GetAccessTokenByCode (code )
125+ resp1 , _ := authenticationClient .IntrospectAccessTokenOffline (tokenResponse .AccessToken )
126+ fmt .Printf ("%+v\n " , resp1 .Id )
127+ resp2 , _ := authenticationClient .IntrospectAccessTokenOffline (tokenResponse .RefreshToken )
128+ resp3 , _ := authenticationClient .IntrospectAccessTokenOffline (tokenResponse .IDToken )
129+ fmt .Printf ("%+v\n " , resp1 )
130+ fmt .Printf ("%+v\n " , resp2 )
131+ fmt .Printf ("%+v\n " , resp3 )
132+ result1 , _ := authenticationClient .IntrospectToken (tokenResponse .AccessToken )
133+ result2 , _ := authenticationClient .IntrospectToken (tokenResponse .RefreshToken )
134+ result3 , _ := authenticationClient .IntrospectToken (tokenResponse .IDToken )
135+ fmt .Printf ("%+v\n " , result1 )
136+ fmt .Printf ("%+v\n " , result2 )
137+ fmt .Printf ("%+v\n " , result3 )
138+ result4 , _ := authenticationClient .RevokeToken (tokenResponse .AccessToken )
139+ fmt .Printf ("%+v\n " , result4 )
146140}
147141
148142func TestIDToken (t * testing.T ) {
0 commit comments