Android , How to access SharePoint data? - android

Basically , I wanted the files in my Company Sharepoint after reading documents provide by microsoft. By using Microsoft Graph authentication API I be able to receive authenticationResult.accessToken by following this example https://github.com/AzureAD/microsoft-authentication-library-for-android
After that I request https://graph.microsoft.com/v1.0/sites/{Mycompany}.sharepoint.com/drives/{Drives ID}/list/items
the response is all the items in that drives.
But
I want to get specific file to display in my application by add item ID
https://graph.microsoft.com/v1.0/sites/{Mycompany}.sharepoint.com/drives/{Drives ID}/list/items/{Item ID}
I got this error
"error": {
"code": "InvalidAuthenticationToken",
"message": "Access token is empty.",
"innerError": {
"date": "2021-02-03T04:57:08",
"request-id": "65b170a7-b864-470e-a1e5-23be9851dd7a",
"client-request-id": "65b170a7-b864-470e-a1e5-23be9851dd7a"
}
}
}
After reading through some Document to find out what wrong with it I'm start to confused with it. Some Document using https://{{tenantName}}.sharepoint.com/Sites.Read.All without using Graph API
example (https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/get-to-know-the-sharepoint-rest-service?tabs=csom)
but this didn't work out for me. Can you guys guide me how this is all work? and how to receive folder and document in Sharepoint
Note
I'm not an expert in Android and new to this kind of stuff.
thank you

The above error is because there is no access token when you were calling the Graph API call. Make sure you pass the header with the HTTP call having access token in Authorization parameter. As suggested by #Dev you can also check in https://jwt.ms and see the access token claims. You can also try the below HTTP call.
https://graph.microsoft.com/v1.0/sites/{siteid}/lists/{listid}/items/{itemid}
in Graph Explorer and you could find the difference.

Related

Deezer Rest API - Add Track to Playlist doesn't work?

I have an Android application integrated with the deezer rest API, and I need to add a track to a playlist.
My application already has Oauth login flow, when I execute the following request:
http://api.deezer.com/user/me?access_token=AJSDH44H5R7SS7SDHDUHFSUDUSUSASDA766
Works fine!
Playlist actions, I trying send this request as:
POST
http://api.deezer.com/playlist/777006545/tracks?access_token=AJSDH44H5R7SS7SDHDUHFSUDUSUSASDA766&songs=2312333,12312
GET
http://api.deezer.com/playlist/777006545/tracks?access_token=AJSDH44H5R7SS7SDHDUHFSUDUSUSASDA766&songs=2312333,12312&request_method=post
Callback error:
{
"error": {
"type": "OAuthException",
"message": "An active access token must be used to query information about the current user",
"code": 200
}
}
But the token works for other requests. What's the right way to do this, anyone know?
Have you checked this page?
https://developers.deezer.com/api/playlist#actions ?
It seems you already have found this one:
https://developers.deezer.com/api/actions-post
Here is what I would test:
POST only.
Check that your access token has the manage_library permission.
Check that the owner of the playlist is the same that the user of the access_token.
It worked for me with:
http://api.deezer.com/playlist/<playlist_id>/tracks?access_token=<access_token>&request_method=post&songs=<track_id>

What kind of data type is transfered between Android Facebook SDK and Facebook Backend?

I'm analyzing some security issues due to an app which uses the Facebook SDK.
a) What type has the data which is transferred between the app and the Facebook backend? Is it JSON? Or is it something else?
b) Furthermore is there a "modern" and secure SSL-Communication used? Do I have to deal with certificates or is that managed by the SDK itself?
The data type transferred is JSON through HTTP GET request-response.
The result JSON it's like:
{
"id" : "32419183519351",
"bithday": "*****",
"name": "Danilo Dughetti",
...
}
For more info try to check the Facebook Graph API.
And for the security question, I know that exists an Acess Tocken system. Actually I don't know if SSL is used.
Hope it can help, bye!

Facebook OauthException code 190 "The Access Token Could Not Be Decrypted"

I am developing an android web app that uses login with facebook functionality. Using the facebook login tutorials I was able to authenticate and create the session on the client side (android). I obtain the access token then forward it to the server so that I can obtain the user profile on the server and start the server session.
The problem is that whenever I try to call the Facebook graph for /me I get that OauthException code 190 that the access token could not be decrypted. I have been reading around and people suggest that this message means the access token is invalid.
I am sure it is not expired because I use it directly after obtaining it.
I also checked the access token debugger. It does not return an error message, it returns the developers.facebook.com url (weird, right?) .
I am lost about where to go from here. I have spent almost 5 days now just reading and trying to debug with no success.
I appreciate any ideas/suggestions.
Thanks
EDIT:
I was able to perform a "/me" request from android, and the response was exactly what I was looking for, when I do it from the server it does not work. I still cannot think of the cause of this issue.

Custom google image search on mobile device

I just need the correct format of the request - https://www.googleapis.com/customsearch/v1?
key=INSERT-YOUR-KEY&cx=013036536707430787589:_pqjad5hr1a&q=flowers&alt=json.
My app will simply make a request with the search phrase and get a callback in JSON. I already connect Google Custom Search to my account, fill in the payment details and get all the keys.
I use the key for Android apps (with certificates), but get the response "Access Not Configured" after call the request in the browser.
How to create a query string to request the API? How can I get the parameter cx?
This is a bug of Google. The problem was solved only completely removing default project and create a new one.

Stuck on scrumptious tutorial, how to get an "active access token"?

The title pretty much sums it up, i am trying to test my Open Graph Actions in the Graph API Explorer but when i POST to /me/mynamespace:myaction, i get this error (Using the access token the Graph API Explorer generated for me, i asked for publish_actions only)
{
"error": {
"message": "(#15) This method must be called with an app access_token.",
"type": "OAuthException",
"code": 15
}
}
Ive done my homework and searched about it, to find a proper access-token to solve this problem goes by the APPID|APP_SECRET format but using that i get
{
"error": {
"message": "An active access token must be used to query information about the current user.",
"type": "OAuthException",
"code": 2500
}
}
Any ideas on how to solve this?
To give out more context the graph actions were created for an android facebook app.
You can't post to /me without a user access token from a user who's logged into your app, 'me' is a placeholder for 'current user'.
It sounds like two things have happened here:
You've configured the Open Graph action to require the App Access Token to post (which is a configuration option on the action
When you came across that error, you tried to use the App Access Token but didnt' change /me/mynamespace:myaction to /<USER ID>/mynamespace:myaction
Some notes:
Never put the app access token into your client code; it can be used to modify app settings. If you really need actions to only be postable via the app access token, you'll need to implement a server-side component to your app which makes the requests with the app access token
You probably need to change the open graph action settings for your action so it can be posted with a user access token
Your method of sending APP_ID|SECRET as an app access token is wrong. To get an app access token, you need to request it via this endpoint:
https://graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID
&client_secret=YOUR_APP_SECRET&grant_type=client_credentials
See here for more details

Categories

Resources