Generate Access Token for Facebook - java

I am new to the Facebook API. What I am trying to do without success is from my laptop create a new access token for myself through the Facebook API.
Below is the URL I am using to create this new access token:
String url = "
https://graph.facebook.com/oauth/authorize?client_id=##########&client_secret=##########&redirect_uri=http%3A%2F%2Fintelligentretrieval.com"
When I use my client id and then the client_secret (I assume this is the client password) then I get an error
{
"error": {
"message": "Missing redirect_uri parameter.",
"type": "OAuthException",
"code": 191
}
}
What exactly is the problem with this and the reason for the error?
Facebook requires a redirect_uri so I decided to dot it to my company site home page.(I figure this isn't the best place to redirect it but where should I redirect this?)
I want to redirect the result (generated access token) to my laptop from where I am making this URL request.
What exactly is the problem with this?
Is this possible with a browser like Chrome?
Is this possible using java?
Also is it possible to extend the access token expiration to 60 days with this url?
Please let me know if there is any confusion with any part of this post or if the answer can be found elsewhere.

Related

Not able to access spotify Get Followed Artists

I am very new into this. Tried to get data from spotify. So tried the what they are provide but its not working. Getting bad request and in response its showing
{
"error": {
"status": 400,
"message": "Client credentials authentication not allowed"
}
}
URL : https://api.spotify.com/v1/me/following?type=artist (Get URL)
Provided Bearer token.
Also I want to understand that how can I pass user id here as if I need to get data for particular user.
Please help me on this.
From the docs (and messing around a bit), I found that the flow should look something like this:
Make a request to the /authorize endpoint with query params: cliend_id, redirect_uri, response_type and scopes (if you're just testing to get a token, use response_type: token)
You will be asked to log in and authorize the scopes (in this case it should be the scope allowing the client to read the user's artists)
In the redirect uri, there will be a token that you can use for the request
https://developer.spotify.com/documentation/general/guides/authorization/code-flow/
https://developer.spotify.com/documentation/general/guides/authorization/scopes/

Yelp android studio VALIDATION_ERROR

I am trying to integrate the YELP API within an application in Android Studio. I am trying to acquire an access token using a post request in Postman. However, when I send the post request I get this error returned in JSON format:
{
"error": {
"code": "VALIDATION_ERROR",
"description": "'client_credentials' is not one of ['authorization_code', 'refresh_token']",
"field": "grant_type",
"instance": "client_credentials"
}
}
I have searched this site and google for what the description line means in particular:
"description": "'client_credentials' is not one of ['authorization_code', 'refresh_token']",
I have not been able to find any results as to what this error means. Here is my project setup in postman:
I simply copy and pasted my client ID and API key from yelp and stored them within the client_id and client_secret in Postman respectively. When I send this requestion I get the 400 Bad Request error and find out that its a validation error. At first I thought that I entered the wrong API key, however, I refreshed the API key and directly copy and pasted it, so I am confident that my API key and client ID are correct. The output should look like this and it should deliver an access token:
I couldn't find any examples that had this specific error message.
You no longer need a refresh token, all you need is an API key in your Authorization header:
Authorization: Bearer {{apiKey}}
Source: https://www.yelp.com/developers/documentation/v3/authentication

https://graph.facebook.com/v2.10/me/photos?access_token=xxxxxx returning error

I am trying to get posts of specific Facebook brand page using following curl command
https://graph.facebook.com/v2.10/me/photos?access_token=xxx
Getting following error
{
"error": {
"message": "An active access token must be used to query information about the current user.",
"type": "OAuthException",
"code": 2500,
"fbtrace_id": "DH1T17dMqR+"
}
}
I have used following curl command to get active access token https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=XXX&client_secret=YYY
Facebook app have been created by page admin and client ID & client secret used to get app access token.
Earlier we are using page-id instead of "me" identifier to get the post using above curl and it was working fine for specific facebook account.
Where page-id is id of specific facebook page whose post you want to get.
Now, same configuration is not working for other page.
The page is most likely restricted by age or location, so you have to use a User Token or Page Token for /page-id/photos.
More information about Tokens:
http://www.devils-heaven.com/facebook-access-tokens/
https://developers.facebook.com/docs/facebook-login/access-tokens/

Microsoft Graph API beta endpoint gives 401 Unauthorized

I am testing the Microsoft Graph beta endpoint that sends invitations to guest users to join the tenant. The endpoint I am using is :
https://graph.microsoft.com/beta/invitations
Body:
{
"invitedUserEmailAddress": "abc#xyz.com",
"inviteRedirectUrl": "https://myDomain"
}
I am passing the bearer token in Authorization header that I got for the local admin user through the ADAL4J api. However, this call gives me a 401 Unauthorized error. Following is the response:
{
"error": {
"code": "InvalidAuthenticationToken",
"message": "Access token validation failure.",
"innerError": {
"request-id": "91f8129e-70cc-467d-a45b-9309e55788d6",
"date": "2017-02-10T08:46:09"
}
}
}
Any clue on how to get this request working? On Github I have gone through other discussions(eg) where users are facing the same issue.
The token sent was obtained with resource as "https://graph.windows.net". The expected resource/audience for Microsoft Graph API is "https://graph.microsoft.com". Update your application manifest to include Microsoft Graph as a resource and request the required permissions. Then request token with above mentioned resource/audience.
I am excatly in the same situation as #adarsh hegde. But I am targetting an azure B2C instead.
I can get the token for the windows graph (using resource "https://graph.windows.net"), and I am able to create users whithin my web app that is registered with the right permission.
What I did is to acquire token for graph.microsoft.com on the same time, but this token doesn't let me use invitations giving me the same error as you :
{
"error": {
"code": "InvalidAuthenticationToken",
"message": "Access token validation failure.",
"innerError": {
"request-id": "91f8129e-70cc-467d-a45b-9309e55788d6",
"date": "2017-02-10T08:46:09"
}
}
}
UPDATE:
So here are the steps that I've done so far:
ADB2C directroy
Web app with OpenID registered in there with required permissions to manage users in the AD following this link
When admin is logged in, the Web app in trusted mode is able to let him manage users (create/add/etc...)
Now what I want to use is the InvitationManager part of the MS graph (graph.microosoft.com) to be able to send invitation mail. can I redeem the code received in the OpenIdConnectAuthenticationNotifications to get access token for the MS graph? knowing that I already do that but for AD graph (graph.windows.net)
Thanks for the help

Facebook graph api change and want a acess key now, how to write new URL

I made some apps, which using fb graph to get the facebook page feed like
https://graph.facebook.com/Troll.Football/photos/uploaded
Using this URL i get all the facebook photos link, and later i downloaded that.
But last week or more exactly after 1st may facebook start to protect this feed using a acess key, they saying
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException",
"code": 104
}
}
I can generate a access token using one of my fb app from user,
but how i use this acess token with my URL.
I mean what will be the new url to access the page photos.
The new url will be the same url with the the access token appended as a parameter
https://graph.facebook.com/Troll.Football/photos/uploaded?access_token=YOUR_ACCESS_TOKEN

Categories

Resources