createToken
inline suspend fun SsoOidcClient.createToken(crossinline block: CreateTokenRequest.Builder.() -> Unit): CreateTokenResponse
Creates and returns access and refresh tokens for clients that are authenticated using client secrets. The access token can be used to fetch short-lived credentials for the assigned AWS accounts or to access application APIs using bearer
authentication.
Samples
fun main() {
//sampleStart
val resp = ssoOidcClient.createToken {
clientId = "_yzkThXVzLWVhc3QtMQEXAMPLECLIENTID"
clientSecret = "VERYLONGSECRETeyJraWQiOiJrZXktMTU2NDAyODA5OSIsImFsZyI6IkhTMzg0In0"
grantType = "urn:ietf:params:oauth:grant-type:device-code"
deviceCode = "yJraWQiOiJrZXktMTU2Njk2ODA4OCIsImFsZyI6IkhTMzIn0EXAMPLEDEVICECODE"
}
//sampleEnd
}
fun main() {
//sampleStart
val resp = ssoOidcClient.createToken {
clientId = "_yzkThXVzLWVhc3QtMQEXAMPLECLIENTID"
clientSecret = "VERYLONGSECRETeyJraWQiOiJrZXktMTU2NDAyODA5OSIsImFsZyI6IkhTMzg0In0"
grantType = "refresh_token"
refreshToken = "aorvJYubGpU6i91YnH7Mfo-AT2fIVa1zCfA_Rvq9yjVKIP3onFmmykuQ7E93y2I-9Nyj-A_sVvMufaLNL0bqnDRtgAkc0:MGUCMFrRsktMRVlWaOR70XGMFGLL0SlcCw4DiYveIiOVx1uK9BbD0gvAddsW3UTLozXKMgIxAJ3qxUvjpnlLIOaaKOoa/FuNgqJVvr9GMwDtnAtlh9iZzAkEXAMPLEREFRESHTOKEN"
scope = listOf<String>(
"codewhisperer:completions"
)
}
//sampleEnd
}