Microsoft Graph Expired Token - jwt

I'm trying to perform a request in Microsoft Graph like this one with Postman
https://graph.windows.net/<Tenant>/users?api-version=1.6
For the Authorization, I'm using Bearer. I'm retrieving the token manually and decoding it here https://jwt.io/ That way I know that it's well formed and that it's not expired yet.
However, I'm getting the following error on the response:
{
"odata.error": {
"code": "Authentication_ExpiredToken",
"message": {
"lang": "en",
"value": "Your access token has expired. Please renew it before submitting the request."
}
}
}
What am I doing wrong?

You an try Get App-Only Access Token with the Microsoft Graph POST API:
https://login.microsoftonline.com/{{TenantID}}/oauth2/v2.0/token

Related

Verify Access Token (Facebook) and fetch user profile details

I have integrated firebase on website and able to get the information.
Now need to validate the accessToken on server which is fetched from web.
1st Step
Generating access_token by using below api
https://graph.facebook.com/oauth/access_token?client_id=1234&client_secret=some_secret&grant_type=client_credentials
which gives below json
{
"access_token": "1234|some_secret_here",
"token_type": "bearer"
}
2nd Step
Now using the access_token fetched from 1st step. Need to fetch user details from facebook and also validate the accessToken fetched from website.
Using below api to do it.
https://graph.facebook.com/debug_token?input_token=accessToken_fetched_web&access_token=1234|some_secret_here
which results in
{
"data": {
"error": {
"code": 190,
"message": "Bad signature"
},
"is_valid": false,
"scopes": []
}
}
Not sure whats the issue. Can someone help me out to validate the accessToken & fetch the user details from Facebook

An accessToken issue using the Graph API

I'm trying to make a GET request from the Facebook Graph API, graph.facebook.com (using Postman, a Chrome application) to get all events containing the key word as below:
graph.facebook.com/v2.8/search?pretty=0&q=<MY_CITY>&type=event&accessToken=<MY_APP_ACCESS_TOKEN>
I'm having this response from Facebook:
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException",
"code": 104,
"fbtrace_id": "B5KWVqr7ajK"
}
}
I've rechecked my app_access_Token, and it's fine and works for other requests. How can I fix this problem?
https://developers.facebook.com/docs/graph-api/using-graph-api/#search:
All Graph API search queries require an access token included in the request. You need a user access token to execute a search.

Getting User Birthday HTTP Request

Im trying to get birthday on the server side of my app.
I have already the ["user_birthday"] permission on my login request.
But now on the server i need to do something like this i guess.
userBirtdhay = "https://graph.facebook.com/me?fields=birthday&" + user.services.facebook.id;
But this results something like.
https://graph.facebook.com/me?fields=birthday&10146450841965723dffsadf
And if you go to the url you get a
{
"error": {
"message": "An active access token must be used to query information about the current user.",
"type": "OAuthException",
"code": 2500
}
}
After Some research got that the me space on the url should be my accessToken so i try with .
https://graph.facebook.com/longAccesToken?fields=birthday&
But it returns now.
"message": "(#803) Some of the aliases you requested do not exist:
This would be correct:
https://graph.facebook.com/me?fields=birthday&access_token=[your-user-token]
You should start reading the Facebook docs about Access Tokens and API endpoints. You can test the API with the API Explorer.

Playframework scala OAuth2 authentication by facebook

There is wonderful tutorial how to use OAuth2 api to be authenticated by github. But if I want to use same api for facebook. I tried following and end up with error. So how can use OAuth2 api for facebook?
fb.client.id=79756xxxxxxxx
fb.client.secret=205adxxxxx
fb.redirect.url= "https://graph.facebook.com/oauth/access_token?client_id=%s&redirect_uri=%s&client_secret=%s&code=%s"
// eventually url is filled as
https://graph.facebook.com/oauth/access_token?toeken&client_id=797565xxxx&redirect_uri=http://localhost:9000/_oauth-callback&client_secret=email&code=e3887ea3-3319-4462-a3b1-xxxxx
// get this error
{
"error": {
"message": "Invalid verification code format.",
"type": "OAuthException",
"code": 100
}
}
Update after updating the request url as
fb.redirect.url="https://graph.facebook.com/oauth/authorize?client_id=%s&redirect_uri=%s"
I managed to get facebook's login prompt. After submitting fb credential my redirect url is called as
http://localhost:9000/_oauth-callback/?code=AQD72MtTesmEIoQty3c0ZTC3a211egWR0pvVcLGhb6lB2T6TslG7r99IouP6KbE4oDYCl7n0_imyI0zxe-8Nb2CUDsRN5pEyQ_Pk6JRwy0JRy3T27kbDJ9DRcr11NrDdlZtNK3tOe6kfTdVQm52YXMTF7L9Kq3N6z0ZIBbVxsizvWZ00kVUL2YkSdnh5mpx4ofKaTgd0pHNhE9X33mBdzS7Evu_R0yW8XqgZFfvEPFE3f1e9qdrbrhwHaj1kfZyk6NigDBpnyZ5CgtzFTDpLHZVKQXCWDNzfqMwlxYuV2amTJUEgq77_HzxnDD3njvU4dJK0lrpVrkimqMeldCFEHzbV#_=_
I don't know how to use this code = XXX. Don't even know what does this code mean? How can ask user public profile info after my redirect url is called? Please let me

facebook graph api error: An access token is required to request this resource

I wanted to publish a link on the given profile on Facebook via the app. Post to https://graph.facebook.com/PROFILE_ID/links with access_token and other necessary parameters.
For testing purpose, I got the access_token with Graph API Explorer and had the publish_stream and share_item extended permission.
Then I got the error
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException",
"code": 104
}
}
I tried fb_id and fb_username for the PROFILE_ID but got the same error. Anything wrong?
Thanks
Yes. /links is read only. To create a link, you need to POST to /USER_ID/feed.
https://developers.facebook.com/docs/reference/api/user/#links