However I dont understand the below point. Which URL do I need to access to get these 2 parameters? I don't understand what is meant by this line (the URL that you have received during the redirection) as after allowing the app it redirects to the redirect_uri value.
Next, you will have to exchange the "access_code" for a real "Access Token". In order to do that, you will have to parse two parameters from the URL (the URL that you have received during the redirection):
Hi yaghwin, if you're adding the Authorization field into the header by hand, remember that the Base64 encoded string must be preceded by "Basic" as in:
@JBilkey, I tried your method too but doesn't work. The submission URL asks me for credentials and when I provide the test credentials it says Error 401
form method="post" action="greenbutton.affsys.com/auth/j_oauth_resolve_access_code">
Grant Type input type="text" name="grant_type" value="authorization_code">
Redirect URI input type="text" name="redirect_uri">
Code input type="text" name="code" value="eyJhbGciOiJSUzI1NiJ9.MDBjZmQxMTYtODFlNC00YmU2LWIyNDYtZThmYTQ2ZTRjMjk2MTM4NzkxNzQ5MDA2MA.MR4OAN3Fis8ySsCwFK_5rn3WHX6MNcIhNP2eDwOZnaW8K79Ya0ag8JuuVXS5wACu3NkVCv5VGwbOgKQTmGSvq0PU9_G0TOncb0LqzvGoO8Gsjh7GAEKGBBiV0NmG6hg_kXjzEAj4Ej5oRN2Lq-Pfpq1MOLyPXf5RIwIeJFuQcnR5woKQIlPRvs30PcWgZRzapVSEAxdWPLvfWNOs91_wtXs4ohOUgRp_KaPircHJZ_gf2Pj0Pykv-sXIxzVEIv-jA-9zY1rvbCL3QQCDjETD7ZT2jpTpkXMwI21bKDhKIH3SBO-tkwwzky-1dS5RE4wJFqnwM2lp9e1XaQw3hoakXg">
input type="submit">
/form>
Hi yaghwin. I suggest you the follow steps
1. read page 3 of this posting where I explained step by step the process
2. You cannot just do step 2 from your form, you have to do step1 and immediatelly step 2. Somebody noted that these requests have to be done one after another.
3. If that doesn't help please provide 2 full requests captured by any http tracing tool, then we can try to analize them. Only that will give us a full picture. For axample in the request above I don't see "redirect_uri" provided. Was it? That why full packet tracing is important
You said "The submission URL asks me for credentials"? What URL is that?
Please do make sure you're doing step 1 before step 2. The credentials you should be using are your registered app's client id and client secret which you use in the authentication steps.
114 comments
yaghwin • almost 10 years ago
hi,
I'm getting stuck at this point
I called the below URL and after logging in and allowing the app it redirects me back to my URL which provides me the "CODE" parameter.
https://greenbutton.affsys.com/auth/signin.jsp?client_id=id-85ffaf0a-777c-4af9-9061-e2bc221941c2&redirect_uri=https%3A%2F%2Fgreenbutton.affsys.com%2Fa3p%2Fmvc%2Fappsetup&state=0%2Fa7fcb34d-271f-4910-a886-2ad617021cfe
However I dont understand the below point. Which URL do I need to access to get these 2 parameters? I don't understand what is meant by this line (the URL that you have received during the redirection) as after allowing the app it redirects to the redirect_uri value.
Next, you will have to exchange the "access_code" for a real "Access Token". In order to do that, you will have to parse two parameters from the URL (the URL that you have received during the redirection):
* code
* State
Please help.
Bianca Sayan • almost 10 years ago
yaghwin,
Make a post request to
"https://greenbutton.affsys.com/auth/j_oauth_resolve_access_code"
Your header should include authorization something like this:
'Authorization: Basic '.base64_encode($client_id.":".$client_secret)
And you should include post parameters of the code, grant_type ("authorization_code"), and the redirect_uri (same as last time).
yaghwin • almost 10 years ago
Thanks biancasayan,
I've created a dummy page with a form and fields for grant_type, code and redirect_uri. The form posts to "https://greenbutton.affsys.com/auth/j_oauth_resolve_access_code"
Also added a header value Authorization: Base64 of client_id:client:secret.
When i click on submit button it asks for username and pwd. I'm providing the test credentials and it throws an 400 error
Any idea what I'm missing here?
I guess I'm unable to set the header properly, any idea how do i do that in jsp ?
Jade Bilkey • almost 10 years ago
Hi yaghwin, if you're adding the Authorization field into the header by hand, remember that the Base64 encoded string must be preceded by "Basic" as in:
Authorization: Basic aWQtYTZhMmZhMDItYzg2Mi00NzI4LWIxNDktNzI2ZWQ2MTRiMDI0OnNlY3JldC1hMDJjNGI4Mi0yYTllLTQ0NzctYWQwMS0wMWQ3OTMyYzhmYjI=
yaghwin • almost 10 years ago
Thanks for your reply
I'm doing this in my jsp
response.setHeader("Authorization: Basic", "aWQtOYTktOWU2ZS00ZmQwLWE1ZWMtNzljN2RmZGI5NzQ1:c2VjcmVjc3ZTBhLTQ1ZjgtNDdjZC1hYjE4LTE5OTA0M2VlZDI0Mw==");
Still doesn't work :(
Jade Bilkey • almost 10 years ago
Yaghwin,
I believe that the function you are using is: http://docs.oracle.com/javaee/7/api/javax/servlet/http/HttpServletResponse.html#setHeader%28java.lang.String,%20java.lang.String%29
In that case, your parameters should be:
response.setHeader("Authorization", "Basic aWQtOYTktOWU2ZS00ZmQwLWE1ZWMtNzljN2RmZGI5NzQ1:c2VjcmVjc3ZTBhLTQ1ZjgtNDdjZC1hYjE4LTE5OTA0M2VlZDI0Mw==");
Bianca Sayan • almost 10 years ago
Yaghwin,
You may want to give us a peek at your POST data, also.
Yuri Shteinman • almost 10 years ago
Just to make sure, You said "I'm providing the test credentials". Where do you get these credentials?
yaghwin • almost 10 years ago
Thanks all for your replies.
Test credentials that are available on the site.
@JBilkey, I tried your method too but doesn't work. The submission URL asks me for credentials and when I provide the test credentials it says Error 401
form method="post" action="greenbutton.affsys.com/auth/j_oauth_resolve_access_code">
Grant Type input type="text" name="grant_type" value="authorization_code">
Redirect URI input type="text" name="redirect_uri">
Code input type="text" name="code" value="eyJhbGciOiJSUzI1NiJ9.MDBjZmQxMTYtODFlNC00YmU2LWIyNDYtZThmYTQ2ZTRjMjk2MTM4NzkxNzQ5MDA2MA.MR4OAN3Fis8ySsCwFK_5rn3WHX6MNcIhNP2eDwOZnaW8K79Ya0ag8JuuVXS5wACu3NkVCv5VGwbOgKQTmGSvq0PU9_G0TOncb0LqzvGoO8Gsjh7GAEKGBBiV0NmG6hg_kXjzEAj4Ej5oRN2Lq-Pfpq1MOLyPXf5RIwIeJFuQcnR5woKQIlPRvs30PcWgZRzapVSEAxdWPLvfWNOs91_wtXs4ohOUgRp_KaPircHJZ_gf2Pj0Pykv-sXIxzVEIv-jA-9zY1rvbCL3QQCDjETD7ZT2jpTpkXMwI21bKDhKIH3SBO-tkwwzky-1dS5RE4wJFqnwM2lp9e1XaQw3hoakXg">
input type="submit">
/form>
yaghwin • almost 10 years ago
any update on the issue?
Yuri Shteinman • almost 10 years ago
Hi yaghwin. I suggest you the follow steps
1. read page 3 of this posting where I explained step by step the process
2. You cannot just do step 2 from your form, you have to do step1 and immediatelly step 2. Somebody noted that these requests have to be done one after another.
3. If that doesn't help please provide 2 full requests captured by any http tracing tool, then we can try to analize them. Only that will give us a full picture. For axample in the request above I don't see "redirect_uri" provided. Was it? That why full packet tracing is important
You said "The submission URL asks me for credentials"? What URL is that?
Jade Bilkey • almost 10 years ago
Yaghwin,
Please do make sure you're doing step 1 before step 2. The credentials you should be using are your registered app's client id and client secret which you use in the authentication steps.
yaghwin • almost 10 years ago
Hi,
I'm using my client id and secret only but still unable to get the access token.
Has anyone implemented this in their java application?
Jade Bilkey • almost 10 years ago
yaghwin,
If you are still having difficulties, I would recommend contacting support directly for faster replies: testbedsupport@powerinform.com