@@ -4,59 +4,10 @@ import (
4
4
"context"
5
5
"fmt"
6
6
"net/http"
7
- "net/url"
8
- "strings"
9
7
)
10
8
11
- // GrantNewAccessTokenFromAuthCode - Use this call to grant a new access token, using the previously obtained authorization code.
12
- // Endpoint: POST /v1/identity/openidconnect/tokenservice
13
- func (c * Client ) GrantNewAccessTokenFromAuthCode (ctx context.Context , code , redirectURI string ) (* TokenResponse , error ) {
14
- token := & TokenResponse {}
15
-
16
- q := url.Values {}
17
- q .Set ("grant_type" , "authorization_code" )
18
- q .Set ("code" , code )
19
- q .Set ("redirect_uri" , redirectURI )
20
-
21
- req , err := http .NewRequestWithContext (ctx , "POST" , fmt .Sprintf ("%s%s" , c .APIBase , "/v1/identity/openidconnect/tokenservice" ), strings .NewReader (q .Encode ()))
22
- if err != nil {
23
- return token , err
24
- }
25
-
26
- req .Header .Add ("Content-Type" , "application/x-www-form-urlencoded" )
27
-
28
- if err = c .SendWithBasicAuth (req , token ); err != nil {
29
- return token , err
30
- }
31
-
32
- return token , nil
33
- }
34
-
35
- // GrantNewAccessTokenFromRefreshToken - Use this call to grant a new access token, using a refresh token.
36
- // Endpoint: POST /v1/identity/openidconnect/tokenservice
37
- func (c * Client ) GrantNewAccessTokenFromRefreshToken (ctx context.Context , refreshToken string ) (* TokenResponse , error ) {
38
- type request struct {
39
- GrantType string `json:"grant_type"`
40
- RefreshToken string `json:"refresh_token"`
41
- }
42
-
43
- token := & TokenResponse {}
44
-
45
- req , err := c .NewRequest (ctx , "POST" , fmt .Sprintf ("%s%s" , c .APIBase , "/v1/identity/openidconnect/tokenservice" ), request {GrantType : "refresh_token" , RefreshToken : refreshToken })
46
- if err != nil {
47
- return token , err
48
- }
49
-
50
- if err = c .SendWithAuth (req , token ); err != nil {
51
- return token , err
52
- }
53
-
54
- return token , nil
55
- }
56
-
57
9
// GetUserInfo - Use this call to retrieve user profile attributes.
58
10
// Endpoint: GET /v1/identity/openidconnect/userinfo/?schema=<Schema>
59
- // Pass the schema that is used to return as per openidconnect protocol. The only supported schema value is openid.
60
11
func (c * Client ) GetUserInfo (ctx context.Context , schema string ) (* UserInfo , error ) {
61
12
u := & UserInfo {}
62
13
0 commit comments