This is regarding the post: BASIC authentication from JAVA to Sharepoint 2013 REST API
I am facing the same problem.
I tried the solutions provided over here but it did not work out for me.
I am trying my luck to get the SharePoint Rest API working with Java but to no avail. It is showing the below error response:
Oct 03, 2017 8:23:49 PM org.apache.http.impl.auth.HttpAuthenticator generateAuthResponse
WARNING: NEGOTIATE authentication error:
No valid credentials provided
(Mechanism level: No valid credentials provided
(Mechanism level: Failed to find any Kerberos tgt))
----------------------------------------
HTTP/1.1 401 Processed
If you have enabled NTLM authentication , then you can try NTLM auth from java. This example might help you , because following the same worked for me .
http://www.muneebahmad.com/index.php/archives/127
If you have Digest type of auth then you can refer this ,
http://www.whypad.com/posts/authenticate-sharepoint-rest-call-in-a-rest-client/1169/
Related
I upgraded from keycloak 18 to 20.0.3.
But now I'm having trouble retrieving roles.
The Error: javax.ws.rs.NotFoundException: HTTP 404 Not Found
This is what i'm trying to do...
RealmResource realmResource = KeycloakHelper.getRealmResource(connectionParameters);
in connectionParameters is the keycloakServerUrl, keycloakServerRealm, user and password
representation = realmResource.roles().get("roleName").toRepresentation();
but the realmResource.roles().get("roleName").toRepresentation() throws a javax.ws.rs.NotFoundException: HTTP 404 Not Found error
I found the problem. You may no longer use /auth in version 20.0.3
UPDATE 2
SOLVED, I was missing Header String tutorial instructions at https://developer.twitter.com/en/docs/basics/authentication/guides/authorizing-a-request.html
Answer to my question: Headers must not contain any json data.
Here's my fully functional project, just insert your credentials and you are ready to send Twitter direct messages:
https://github.com/ricarrrdo/gs-rest-service
Note: I'm using Spring deprecated AsyncRestTemplate, so if someone knows how to use the new WebClient, please upgrade restASyncClientBody() method inside Application.java - it would be much appreciated!
UPDATE 1
https://github.com/ricarrrdo/gs-rest-service/blob/master/src/main/java/hello/Application.java#L2-L12
This link above is my spring boot project which recreates Twitter given example at https://developer.twitter.com/en/docs/basics/authentication/guides/creating-a-signature.html to authenticate and authorize a API request.
It's working fine, just compile/run with mvn spring-boot:run and watch console output.
You can check lines 41-52, which are the same parameters used in Twitter example.
Problem/Question
I'm trying to send a Direct Message on Twitter via Twitter API but I keep getting Bad Authentication data error. How should I change my code to be able to send direct messages?
I mean: In https://developer.twitter.com/en/docs/basics/authentication/guides/creating-a-signature.html there's an example with how to create a valid Oauth header using x-www-form-urlencoded parameters. But how can I create valid Oauth headers when sending Json?
Twitter tutorial for direct messages here -
https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/new-event
Notes
Authorization header needed to send a direct message:
authorization: OAuth oauth_consumer_key="YOUR_CONSUMER_KEY",
oauth_nonce="AUTO_GENERATED_NONCE",
oauth_signature="AUTO_GENERATED_SIGNATURE",
oauth_signature_method="HMAC-SHA1",
oauth_timestamp="AUTO_GENERATED_TIMESTAMP",
oauth_token="USERS_ACCESS_TOKEN", oauth_version="1.0"
I am developing few REST webservices using Java Servlet. I would like to use google OAuth2 for authenticating my client and use oauth token for exposing my webservices.
As per the guideline on following url: Using OAuth 2.0 to Access Google APIs
For Web Apps I followed below steps:
Registered my application with Google development console.
Created new Client ID and Client secret.
After that I have used below Google authentication end point to generate authorization code on server: https://accounts.google.com/o/oauth2/auth
With query parameter define here: Using OAuth 2.0 for Web Server Applications
Response of above URL gives me authorization code as query paramters, I use that code to generate oauth Token using https connection.
https://www.googleapis.com/oauth2/v3/token
Query parameters are
code
client_id
client_secret
redirect_uri
grant_type
When I call https://www.googleapis.com/oauth2/v3/token service to generate oauth token from server, I am getting Java Exception.
java.security.AccessControlException: access denied ("java.net.SocketPermission" "www.googleapis.com:443" "connect,resolve")
Please help me if I missing any configuration or am doing something wrong.
I want to implement XOAuth 2.0 for my web application in Java.
My application asks for username and password from the user. Now using these credentials I want to authenticate the user through Gmail.
Please suggest libraries, and also how to implement it??
I am new to authentication using Gmail. Need some suggestions.
as I know the purpose of the OAuth 2.0 is to prevent leak of the user's credentials into 3rd party applications.
The abstract flow shows how client (3rd party app) should use the access_token (retrieved with one of the grant types) to access resource.
The specification also defines the basic HTTPS calls to use for example in case of an authorization code grant type (I think this flow best suits for you). This has 2 request, one for the code (user agent redirection is used to send the code to the 3rd party app) and one for the access_token.
Authorization code request&response
GET /authorize?response_type=code&client_id=s6BhdRkqt3&state=xyz
&redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb HTTP/1.1
Host: server.example.com
HTTP/1.1 302 Found
Location: https://client.example.com/cb?code=SplxlOBeZQQYbYS6WxSbIA
&state=xyz
Token request&response:
POST /token HTTP/1.1
Host: server.example.com
Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code&code=SplxlOBeZQQYbYS6WxSbIA
&redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Cache-Control: no-store
Pragma: no-cache
{
"access_token":"2YotnFZFEjr1zCsicMWpAA",
"token_type":"example",
"expires_in":3600,
"refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA",
"example_parameter":"example_value"
}
So you do not need to ask a user for the GMail credentials.
Here you can find a spring-security example for an OAuth 2.0 compliant application.
I hope I could help.
Since last Feb 20th, while trying to access the Google Drive through Google Picker, i am getting the following error:
"Invalid credentials (missing or invalid oAuth token)"
The application feature has been working since the beggining, and now it has stopped working.
Anyone can enlight me on this matter?
Thanks,
They now require OAuth tokens for everyone requesting Views that deal with user data.
Check this announcement, it contains the details and it helped in my case.