2016-10-13 8 views
1

私はOauthを初めて使用しています。私は、xml コンフィグレーションでSpring Oauth2のアプリケーションを持っています。 http://www.beingjavaguys.com/2014/10/spring-security-oauth2-integration.htmlSpring oauth2認可プロバイダ

からの基準をとっているので、トークンを取得するには、以下のURLは、それがトークンreseponseを与える

http://localhost:8080/SpringRestSecurityOauth/oauth/token?grant_type=password&client_id=restapp&client_secret=restapp&username=beingjavaguys&[email protected] 

です。 したがってここでは、要求URLのclient_idがXMLファイル内にハードコードされています。実行時にclientId、grantTypeを送信します。 ここではどのようなことをする必要があります。

答えて

0

通常、headerにclient_id/client_secretを送信します。

OAuth2は、送信される秘密データがあるためhttpsが使用されている場合にのみ安全です。ここ

例(angularjs):ここで郵便配達からカールに

auth = 'Basic ' + window.btoa(client_id + ':' + client_secret); 
    $http.defaults.headers.common.Authorization = auth; 
    $http.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 
    grantparam= 'grant_type=password&username='+loginData.username + '&password=' + loginData.password; 
    $http.post('https://localhost:8123/oauth/token?'+grantparam) 

curl -X POST -H "Accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" -H "Authorization: Basic 111111111111111" -H "Cache-Control: no-cache" -H "Postman-Token: 11111111-111111111111111" "https://localhost:8443/sf/api/oauth/token?grant_type=password&username=11111111111&password=**********" 
関連する問題