Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AJAX call how to pass (-vu clientapp:123456) #24

Open
dkakollu opened this issue Jun 17, 2015 · 7 comments
Open

AJAX call how to pass (-vu clientapp:123456) #24

dkakollu opened this issue Jun 17, 2015 · 7 comments
Labels

Comments

@dkakollu
Copy link

HI Roy,

Thank you for spring-rest-service-oauth.

I have small issue when I try to run with curl command its working fine no issues, but when we try to
run with AJAX call how to pass (-vu clientapp:123456), without -vu clientapp:123456 I am getting "Full authentication is required to access this resource", please could you suggest me on this.

I am trying with swagger also, for principal parameter I am passing clientapp:123456, but an getting the same error "Full authentication is required to access this resource".

Thank you

Regards
-Durga K

@karthiksrinivasan
Copy link

Instead of clientapp:123456, you should set Authorization header to your ajax call.

It will look something like this.
Authorization = Bearer

@dkakollu
Copy link
Author

Hi Karthik Srinivasan,

Thank you for response, but not working.

when I ran with curl command:

curl -X POST -vu clientapp:123456 http://localhost:8080/oauth/token -H "Accept: application/json" -d "password=admin&username=admin&grant_type=password&scope=read%20write&client_secret=123456&client_id=clientapp"

with out passing -vu clientapp:123456 on curl also I am getting same error "
"Full authentication is required to access this resource".

Thank you

Regards
-Durga K.

@royclarkson
Copy link
Owner

This is just standard OAuth 2 flows illustrating a password grant (based on HTTP Basic auth). There are different types of OAuth 2 flows. Regardless of the client technology and language, you'll need to construct the HTTP requests in a similar manner. See this test as an example.

@royclarkson
Copy link
Owner

the -u curl parameter is simply a shortcut for setting the auth header in the request

-u, --user <user:password>
              Specify the user name and password to use for server authentication. Overrides -n, --netrc and --netrc-optional.

              If you simply specify the user name, curl will prompt for a password.

              The  user  name  and  passwords are split up on the first colon, which makes it impossible to use a colon in the user name with
              this option. The password can, still.

              If you use an SSPI-enabled curl binary and perform NTLM authentication, you can force curl to select the user name and password
              from your environment by specifying a single colon with this option: "-u :".

              If this option is used several times, the last one will be used.

@karthiksrinivasan
Copy link

curl -X POST http://localhost:8080/oauth/token -H "Accept: application/json" -H "Authorization: Basic Y2xpZW50YXBwOjEyMzQ1Ng==" -d "password=admin&username=admin&grant_type=password&scope=read%20write&client_secret=123456&client_id=clientapp"

This may work

@Eitol
Copy link

Eitol commented Apr 20, 2016

Hi, What does Y2xpZW50YXBwOjEyMzQ1Ng == ?

@lndt-cv
Copy link

lndt-cv commented May 10, 2016

Hi, What does Y2xpZW50YXBwOjEyMzQ1Ng == ?
=> This is String authorization = "Basic " + new String(Base64Utils.encode("clientapp:123456".getBytes()));

I have tried many way but unsucceed. I have problem with "-vu clientapp:123456". I run unit test "greetingAuthorized" is ok.
What is "clientapp:123456" and how to use? (I have read the " royclarkson commented on Jun 17, 2015" but not clearly)

2016-05-10_11-43-10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants