2016-07-21 19 views
1

ローカルのJHipsterサーバーで認証用のOAuth2トークンを取得しようとしています。 すべてが正しくセットアップされていて、Web GUIからログインできます。 しかし、私はPOST method not allowedJHipster OAuthがトークンを取得できません - 405エラー

私のcURLのrequesを取得cURLを介して、トークンを取得しようと、次のとおりです。jhipsterアプリ(3.5.0)を生成

curl -X POST -vu client:secret http://localhost:8080/oauth/token -H "Accept: application/json" -d "username=admin&password=admin&grant_type=password&scope=read&client_id=CLIENTID&client_secret=CLIENTSECRET"

+1

おそらくhttp://stackoverflow.com/a/34834735/1098564を探していますか?私はあなたが ""をbase64-encodeする必要があると思うし、あなたはおそらく本体にもう一度それを必要としません。 – sdoxsee

+0

これはうまくいきませんでした。 –

答えて

0

のデフォルトを使用して、これはあなたが希望する方法であります

> curl -X POST -u jhipsterapp:my-secret-token-to-change-in-production -i -H 'Accept:application/json' http://localhost:8080/oauth/token -d "username=admin&password=admin&grant_type=password&scope=read%20write" 

HTTP/1.1 200 OK 
Server: Apache-Coyote/1.1 
X-Application-Context: jhipster:swagger,dev:8080 
Cache-Control: no-store 
Pragma: no-cache 
X-Content-Type-Options: nosniff 
X-XSS-Protection: 1; mode=block 
X-Frame-Options: DENY 
Content-Type: application/json;charset=UTF-8 
Transfer-Encoding: chunked 
Date: Fri, 22 Jul 2016 13:09:38 GMT 

{ 
    "access_token" : "4a1ae413-5cd7-46e9-8a33-31698218d43e", 
    "token_type" : "bearer", 
    "refresh_token" : "537f231c-e6e0-4499-bbd8-9580eee02f79", 
    "expires_in" : 1799, 
    "scope" : "read write" 
} 

注:ここで私の.yo-rc.jsonです:

{ 
    "generator-jhipster": { 
    "jhipsterVersion": "3.5.0", 
    "baseName": "jhipster", 
    "packageName": "com.mycompany.myapp", 
    "packageFolder": "com/mycompany/myapp", 
    "serverPort": "8080", 
    "authenticationType": "oauth2", 
    "hibernateCache": "ehcache", 
    "clusteredHttpSession": "no", 
    "websocket": "no", 
    "databaseType": "sql", 
    "devDatabaseType": "h2Disk", 
    "prodDatabaseType": "mysql", 
    "searchEngine": "no", 
    "buildTool": "maven", 
    "useSass": false, 
    "applicationType": "monolith", 
    "testFrameworks": [ 
     "gatling" 
    ], 
    "jhiPrefix": "jhi", 
    "enableTranslation": true, 
    "nativeLanguage": "en", 
    "languages": [ 
     "en" 
    ] 
    } 
} 
adminユーザーのトークンカール
+0

jhipsterでOAuthサンプルをgithubから取得すると、そのリクエストで401が取得され、カスタムジップスターにはさらにいくつかのオプションが組み込まれているので、405が取得されます。 –

+0

サンプルが異なるクライアントIDを使用しているからです:https://github.com/jhipster/jhipster-sample-app-oauth2/blob/master/src/main/resources/config/application-dev.yml#L69 Btw didカスタムアプリで管理者パスワードを変更しますか? – sdoxsee

関連する問題