OAuth徹底入門(4)

KeycloakへRestしてみた

前提

実際に投げたRequest


@baseuri = http://localhost:8080/

@admin_username= admin
@admin_password=admin
@admin_client_id=admin-cli

### get admin token
# @name admintoken
POST realms/master/protocol/openid-connect/token
Content-Type: application/x-www-form-urlencoded

username=&password=&grant_type=password&client_id=

### set admin token
@admin_access_token = 
@admin_refresh_token = 

### refresh_token
# @name adminrefreshtoken
POST realms/master/protocol/openid-connect/token
Content-Type: application/x-www-form-urlencoded

grant_type=refresh_token&client_id=&refresh_token=

### refresh after set admin token
@admin_access_token = 
@admin_refresh_token = 

### get realm

GET admin/realms
Authorization: Bearer 
Content-Type: application/json

### create realm

POST admin/realms
Authorization: Bearer 
Content-Type: application/json

{"realm": "new-realm", "enabled": true}


### get users
@target_reamlm = new-realm

GET admin/realms//users
Authorization: Bearer 

### add user to realm
@target_realm = new-realm
POST admin/realms//users
Authorization: Bearer 
Content-Type: application/json

{
    "username" : "realmuser"
    , "enabled" : true
    , "totp": false
    , "emailVerified" : true
    , "firstName" : "rest"
    , "lastName" : "api"
    , "email": "email@example.co.jp"
    , "credentials" : [
        {
        "temporary": false
        , "type": "password"
        , "value" : "password"
    }]
    ,"access": {
      "manageGroupMembership": true,
      "view": true,
      "mapRoles": true,
      "impersonate": true,
      "manage": true
    }
}


### get token from customer
# @name customertoken

@target_realm=new-realm
@client_id={作成したclient_id}
@client_secret={作成したclient_secret}
@authcode={authcodeはよしなに}
@redirect_uri=http://127.0.0.1:9090/callback
POST realms//protocol/openid-connect/token
Content-Type: application/x-www-form-urlencoded

client_id=&client_secret=&code=&redirect_uri=&grant_type=authorization_code

### set admin token
@customer_access_token = 
@customer_refresh_token = 

関連記事