Project I am using: ImgurNet from nuget (source: https://github.com/0xdeafcafe/ImgurNet)
It seems like it needs all those parameters:
{
"client_id": "Insert your imgur client_id here",
"client_secret": "Insert your imgur client_secret here",
"access_token": "Insert your imgur access_token here",
"refresh_token": "Insert your imgur refresh_token here",
"authorized_username": "Insert your imgur username here"
}
...while in imgur I am only able to get client_id
+ client_secret
.
The Imgur API documentation mentions those, but doesn't say how to get them: https://api.imgur.com/oauth2
Extra details:
I use ImgurNet
because it is the only imgur api nuget package that I've been able to install in my Xamarin project (all the other ones were not compatible).
This is an example of the code I'm using:
var oauth2Authentication = new OAuth2Authentication("my_client_id", "my_client_secret", false);
var imgurClient = new Imgur(oauth2Authentication);
var imageEndpoint = new ImageEndpoint(imgurClient);
var result = imageEndpoint.UploadImageFromBinaryAsync(imageBinary, title: "my title", description: "my description").Result;
And the exception thrown is "Your OAuth AccessToken has expired" (I then refreshed the client_secret
with the exact same result).
From the imgur documentation:
If a user has authorized their account but you no longer have a valid access_token for them, then a new one can be generated by using the refresh_token.
...so refresh_token
seems necessary regardless.
client_id
andclient_secret
, but notaccess_token
andrefresh_token
. – Nuclideaccess_token
is in the "Authorization" section: "To access a user's account, the user must first authorize your application so that you can get an access token. Requesting an access token is fairly straightforward: point a browser (pop-up, or full page redirect if needed) to a URL and include a set of query string parameters."https://api.imgur.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&response_type=REQUESTED_RESPONSE_TYPE&state=APPLICATION_STATE
– Adila