I'm using msgraph-sdk-java-auth through an application that I've created.
I'm trying to get data from Microsoft Azure with the object AuthorizationCodeProvider but I'm not able to understand how to get the AUTHORIZATION_CODEparameter.
Somebody knows how to use this class?
Thanks!
As far as I know, AUTHORIZATION_CODE is the Authorization Code received from the initial authorize call. You could find the authorization_code in the Steps to get authorizationCode from the sample.
Related
I have an application in whick an user can login with google. Than the user during his experience into the application can choose to integrate also the GoogleCalendar service. In order to achieve this my actual system works like the follow:
-when the user log in with google the system store his access and refresh token and calls Google to retrive basic profile information. In order to do that I create a GoogleCalendar object using the following call:
GoogleTokenResponse response = flow.newTokenRequest(code).setRedirectUri(GOOGLE_CALLBACK_URI).execute();
GoogleCredential credential= new GoogleCredential.Builder().setJsonFactory(Constants.JSON_FACTORY)
.setTransport(Constants.HTTP_TRANSPORT).setClientSecrets(Constants.GOOGLE_CLIENT_ID, Constants.GOOGLE_CLIENT_SECRET).build();
credential.setAccessToken(response.getAccessToken());
credential.setRefreshToken(response.getRefreshToken());
-When the user choose to integrate the calendar service another Oauth iteration starts and the with a new code. I ask the GoogleCredential like before and access the service.
-When the systems need to perform some operations accessing Google Calendar I create a GoogleCredential object with the following call:
GoogleCredential c= new GoogleCredential.Builder().setJsonFactory(Constants.JSON_FACTORY)
.setTransport(Constants.HTTP_TRANSPORT).setClientSecrets(Constants.GOOGLE_CLIENT_ID, Constants.GOOGLE_CLIENT_SECRET).build()
.setAccessToken(user.getAccessToken()).setRefreshToken(user.getRefreshToken());
Ans then ask for the service. But in this last case I get an error reporting 403 code and "Insufficient Permission" message.
I have checked that the stored access and refresh token I set into the GoogleCredential are the same I receive the first time getting the GoogleCredential with the "code". I also search a lot online but no solution would work. I'm really blocked into this error. Thank you in advance for the help and sorry if I miss specifing something or if I make some mistake in asking the question.
If I understand the problem you're describing correctly, incremental authorization may be what you're looking for: https://developers.google.com/accounts/docs/OAuth2WebServer#incrementalAuth
Specifically, add include_granted_scopes=true to your authorization URLs which should cause the resulting tokens to include the sum of all so-far-granted authorizations.
I am new to netsuite.I need to do a upsert opertaion using netsuite in my implemenation class. I am trying to pass my upsertrequest object to netsuite using upsert operation method(generated by using netsuite wsdl). I need to pass the object to the netsuite using my credentials and password.
I have imported netsuite login class loginrequest,loginresponse in my implementation to do the login using my credentials,
how do i need to do the login by passing my credentials to netsuite using java code? whether do i need to use http client or SOAP to send the upsertrequest object and credentials to do login?
eg:
emailid: test#gmail.com
password:test
account_id: 123
Have you taken a look at the sample applications provided by Netsuite? They are a very useful tool and probably will help you answer your question. You can find them here: http://www.netsuite.com/portal/developers/resources/suitetalk-sample-applications.shtml
From What I know: (I normally use php to interact with Netsuite, so my knowledge is limited, but I have used java a few times)
You will need to use SOAP to upsert the object. Once you have logged in by creating a new NsClientObject, you simply call the appropriate method on the create object. This will automatically take care of authentication.
ns = new NSClient();//assumes you have set your credentials in nsclient.properties in the root of the project
ns.callRelevantMethod();
If you are interested in php code, there are plenty of examples on my blog (Netsuite sample code)
Also http://usergroup.netsuite.com is a forum where you can see lots of sample code and netsuite developers will often post responses to inquires. You may want to try that too.
Does that help at all?
FB is sending me a non-URL safe code. While implementing the oauth authentication, FB is sending me a code parameter that is non-url safe.
When i authorize the app i am getting the code parameter with the below value which is not url safe.
AQBQnGZgFNv5EcIB9hZI20GcUgBWru7TE-p_G5NB2HQLX87fyc463aM0BIAiBg_PwRiIuyo0KS1vrDLOLB_SQ0goY31RrNYtZ23lOeaOkGzztarMYH8bJpSYjFOgiXbPhcP6h9YCsizekmcbLpPX_3F7qhsZOLM37UGI7QysvyYOvptpgJ-fm5t-eSViIU_CQH8jTPcQu3BylUVIXS0cEt5T#___=_
When FB is redirecting the control to the my url which is a java web application, i tried to get the code parameter using the code "request.getParameter(CODE)" But i am getting only
AQBQnGZgFNv5EcIB9hZI20GcUgBWru7TE-p_G5NB2HQLX87fyc463aM0BIAiBg_PwRiIuyo0KS1vrDLOLB_SQ0goY31RrNYtZ23lOeaOkGzztarMYH8bJpSYjFOgiXbPhcP6h9YCsizekmcbLpPX_3F7qhsZOLM37UGI7QysvyYOvptpgJ-fm5t-eSViIU_CQH8jTPcQu3BylUVIXS0cEt5T
without #___=_
so i am not able to continue further. But i manually add it to the parameter to fetch the access token it is working fine.
Why is this happening? Please help me.
i think this is signed_request code.
You doesn't need the #_=_ trail to get further, it's not a part of signed_request or code for OAuth2. If you can proceed to further steps it's something other that this.
Once you get code passed to redirect_uri URL you can continue with authentication:
In order to authenticate your app, you must pass the authorization code and your app secret to the Graph API token endpoint - along with the exact same redirect_uri used above - at https://graph.facebook.com/oauth/access_token.
https://graph.facebook.com/oauth/access_token?
client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&
client_secret=YOUR_APP_SECRET&code=THE_CODE_FROM_ABOVE
I want to get a home timeline from twitter and I was able to get the home timeline using twitter4j and oauth authentication method
ConfigurationBuilder confBuilder = new ConfigurationBuilder();
confBuilder.setOAuthAccessToken(accessToken.getToken())
.setOAuthAccessTokenSecret(accessToken.getTokenSecret())
.setOAuthConsumerKey(key)
.setOAuthConsumerSecret(secret);
Twitter twit = new TwitterFactory(confBuilder.build()).getInstance();
User user = twitter.verifyCredentials();
List<Status> statuses = twitter.getHomeTimeline();
but the result is not in the form of .xml or JSON. i also tried
WebResource resource = client.resource("https://api.twitter.com/1/statuses/user_timeline.json");
but all I get is GET https://api.twitter.com/1/statuses/user_timeline.json returned a response status of 401 Unauthorized
I googled many times but I just cant get it right. Please I need a sample java code of how to do it. Complete code that can run right away would be really helpful as I got a lot of partially coded program and just couldnt get it to work. thank you in advance
OK, so after looking at the release notes for the 2.2.x versions, it appears there is a way to get the JSON representation from Twitter4J, but it's disabled by default since it uses some extra memory.
So, you need to:
Enable the JSONStore using the jsonStoreEnabled config option
Get the JSON representation of a request using the getRawJson method
Sorry there's no code example, I haven't tried it myself.
401 Unauthorized:
Authentication credentials were missing or incorrect.
You need to authenticate before you perform the query.
I am using Java Scribe + Spring MVC to access Facebook authentication API.
However, the URL with the access token I am getting back from Facebook is in this format:
/facebookCallback#access_token=[long chunk]&expires_in=5028
As you can see, the access_token is preceded by a #, which disallows me from obtaining the access_code as a normal parameter.
Is there any reason why Facebook is appending the # instead of a ?
var hash = document.location.hash;
I think you mean Javascript , and not Java Scribe ?
you are probably using the callback parameter which is designed for the JS library. Make sure you are not sending an incorrect parameter for "type".
Turns out that it probably was caused by my school network. I tried the exact same code both in school and at home and got different results (school - error, home - correct).
The problem solved by itself the next day in school so I won't be able to find out exactly why. Thanks to those who helped.