github.com/optim-corp/cios-golang-sdk@v0.5.1/sdk/service/authorization/README.md (about) 1 # Authorization 2 3 ## How to set Token 4 5 ```go 6 ctx := ciosctx.WithToken(context.Background(), "Bearer Hogehoge") 7 ``` 8 9 ## How to Auto Refresh Auth 10 11 ```go 12 client := ciossdk.NewCiosClient(ciossdk.CiosClientConfig{ 13 AutoRefresh: true, 14 AuthConfig: ciossdk.RefreshTokenAuth("client_id", "client_secret", "refresh_token", "scope"), 15 }) 16 ``` 17 18 ## How to Auto Client Auth 19 20 ```go 21 client := ciossdk.NewCiosClient(ciossdk.CiosClientConfig{ 22 AutoRefresh: true, 23 AuthConfig: ciossdk.ClientAuthConf("client_id", "client_secret, "scope"), 24 }) 25 ``` 26 27 ## How to Auto Device Auth 28 29 ```go 30 client := ciossdk.NewCiosClient(ciossdk.CiosClientConfig{ 31 AutoRefresh: true, 32 AuthConfig: ciossdk.DeviceAuthConf("client_id", "client_secret", "assertion", "scope"), 33 }) 34 ``` 35 36 ## Get Token 37 38 ### interface 39 40 ``` 41 GetAccessTokenByRefreshToken() (sdkmodel.AccessToken, sdkmodel.Scope, sdkmodel.TokenType, sdkmodel.ExpiresIn, error) 42 GetAccessTokenOnClient() (sdkmodel.AccessToken, sdkmodel.Scope, sdkmodel.TokenType, sdkmodel.ExpiresIn, error) 43 GetAccessTokenOnDevice() (sdkmodel.AccessToken, sdkmodel.Scope, sdkmodel.TokenType, sdkmodel.ExpiresIn, error) 44 SetClientSecret(clientSecret string) 45 SetClientId(clientId string) 46 SetRef(ref string) 47 SetAssertion(assertion string) 48 SetDebug(debug bool) 49 SetScope(scope string) 50 ``` 51 52 ### Usage 53 54 #### Get an AccessToken by refresh token 55 56 ※ Fix in the future 57 ```go 58 token, scope, tokenType, expiresIn, err := client.Auth().GetAccessTokenByRefreshToken() 59 ``` 60 61 #### Get an AccessToken by client 62 63 ※ Fix in the future 64 ```go 65 token, scope, tokenType, expiresIn, err := client.Auth().GetAccessTokenOnClient() 66 ``` 67 68 #### Get an AccessToken by device 69 70 ※ Fix in the future 71 ```go 72 token, scope, tokenType, expiresIn, err := client.Auth().GetAccessTokenOnDevice() 73 ```