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
Related
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.
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>
Situation
I have simple android app where user gets data from Google Fusion Tables with REST api. For this I was using OAuth 2 authorization to get Access Token and Refresh Token. I have web view in my app which will show login screen as well as consent screen. I was planning to get access token from web view and use it for further API calls. I am using retrofit to execute my http calls. I use following query parameters,
"client_id" = CLIENTID
"client_secret" = SECRET
"code" = 4/XXXXXXXXXX //Code got from redirect url
"grant_type" = "authorization_code"
"access_type" = "offline"
"approval_prompt" = "force"
"redirect_uri" = REDIRECT_URL
So far so good. But when I exceute post request with above query parameters, I get following response,
{
"access_token": "ya29.XXXXXXXXXXXXXX",
"token_type": "Bearer",
"expires_in": 3599,
"id_token": "XXXXXXXXXX"
}
Question
Where is refresh token? I need refresh token because I couldn't do API call through app later on with access token and I don't want user to get access token every time.
What I have tried
I have already followed instructions from this post and have tried revoking permission to application from settings. I have also tried using different google accounts in case there was some permission issue, but still no luck. I have also tried removing query parameter "approval_prompt" and "grant_type" but that also didn't help.
I got answer after searching and banging head for 5-6 hours. This answer saved me! Answer to people looking for this in future,
Add "access_type" = "offline" query while requesting for access token rather than exchanging, i.e. in URL which asks for consent.
Instead of specifying grant_type=offline in the authorization request, you need to provide access_type=offline to request a refresh token.
I'm trying to implement one-time code sign in flow in my system.
Application contains of two parts:
1)Android application which requests Google+ for one-time authorization code
2)Rails server that receives one-time code from android application in request header and tries to exchange code for access_token and id_token from Google+
The problem is that everything works well if I get one-time code using JavaScript sign-in button in browser, but doesn't work when one-time code is obtained by Android application and then sent to my server.
I'm getting always
"error" : "redirect_uri_mismatch"
My server settings are following:
{ "web":
{ "client_id": "MY_REGISTERED_WEB_APP_CLIENT_ID",
"client_secret": "MY_CLIENT_SECRET",
"redirect_uris": ["postmessage"],
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token"
}
}
Now, how I'm requesting one-time code from Android app:
I use the same MY_REGISTERED_WEB_APP_CLIENT_ID as on my server for requesting one-time code. I don't know, maybe I have to use on Android another client id, that corresponds to my Android application? But all found documentation and articles are pointing to registered
Web app client_id.
Or maybe my rails server should be configured not for web, but for installed type of registered in Google Console apps?
Now regarding redirect_uris.
I've tried to set several redirect_uris in Google Console:
empty field
http://localhost:5000
https://localhost:5000
http://my.deployment.url/auth2callback
Web origins in Google console are set to
- http://my.deployment.url
- http://localhost:5000
Can't figure out what I'm doing wrong.
Actually I don't understand why I need to set this redirect_uris values, since I don't want to have callbacks from Google, I just want to get access_token and use it for accessing Google+.
This is happening because the redirect_uri your android app is using to create the initial login flow is different from the redirect_uri the server is using when it tries to excange the code for an access_token. The redirect_uri the user returns to and the redirect_uri used in the token exchange must match.
The proper redirect_uri in this case is "urn:ietf:wg:oauth:2.0:oob"
Actually we created an app inside facebook and using the app id provided, the android application was able to post messages.
Recently we changed the facebook username and primary email address.
After this, our app stopped working on the facebook login. It doesnt event show us the facebook login screen in the webview.
We are getting the following exception
{
"error": {
"message": "Error validating application. Invalid application ID.",
"type": "OAuthException",
"code": 101
}
}
Will be happy is someone helps us out in this.
Thanks in advance.
Your app's code references an app ID, which is needed for the app to work with Facebook's API - If you cannot access that app ID via the API (a GET request to graph.facebook.com/<app ID here> will return an 'Unsupported GET request' error for an inaccessible app) it means that it's either in sandbox mode, and you can fix this from the app settings, or it's been deleted.
If the latter you'll need to create a new app and update your Android code to use that new App's app ID instead