I'm trying to get the username of the owner of the picture I'm tagged in. However, when I try to go to my request url, taking error below. Researched about this case but couldn't find something useful about this situation.
{ "error": { "message": "Invalid OAuth access token - Cannot parse access token", "type": "OAuthException", "code": 190, "fbtrace_id": "ALI1tNJ_alXBJmnJWK-w0vq" } }
`
By the way when I try to get my profile media's and other fields, having no trouble about that. Here's my source codes:
public class SocialFeedService
{
private readonly string instagramBaseAPIUrl = "https://graph.instagram.com/";
private readonly string facebookBaseAPIUrl = "https://graph.facebook.com/";
public string GetInstagramContents(string userToken)
{
using (var client = new HttpClient())
{
try
{
string mediaUrl = $"me/media?fields=id,tags,mentions,username,timestamp,caption,media_url,media_type,permalink&access_token={userToken}";
string tagUrl = $"me/tags?fields=id,username&access_token={userToken}";
string fullMediaUrl = $"{this.instagramBaseAPIUrl}{mediaUrl}";
string fullTagUrl = $"{this.facebookBaseAPIUrl}{tagUrl}";
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var response = client.GetStringAsync(new Uri(fullTagUrl)).Result;
if (!string.IsNullOrEmpty(response))
{
var result = response;
return result;
}
return string.Empty;
}
catch (Exception ex)
{
throw ex;
}
}
}
}
And here is my controller :
public class XControllers : ControllerBase
{
IConfiguration configuration;
public XControllers(IConfiguration configuration)
{
this.configuration = configuration;
}
[HttpGet]
public IActionResult Get()
{
string token = @"IG...";
var service = new SocialFeedService();
string result = service.GetInstagramContents(token);
return Ok(result);
}
}
Thanks in advance.
Just trying to take tagged media owner's username.
There could be several reasons why you receive an invalid token
error for OAuth. I would recommend ruling out a few of the following:
access_token
wasn't properly passed in the Authorization header access_token
was used (included a typo, invalid string, etc.)access_token
was expired (typically lasts for 1 hour) You might also find this guide on OAuth Troubleshooting tips helpful.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.