Closed apacha closed 6 years ago
Hey @apacha,
The OAuth endpoints should "just work" in the same way as unsigned endpoints. The wrapper handles the OAuth authentication automatically by looking for the OAuthSigned attribute.
I'l leave this open so we can make this clearer in the documentation - feel free to PR.
I was hoping to find a working example that shows how to do the following things, required to work as authenticated user:
I partially used Google OAuth, DotNetOpenAuth and some other sources, such as a demo how to do OAuth with Spotify to get it running, but it took me hours and it would be great if you could provide a small sample where the user can basically enter his credentials and the library will handle the rest, e.g. ISevenDigitalOAuthProvider sevenDigitalOAuthProvider = new SevenDigitalOAuthProvider();
IOAuthCredentials oauthCredentials = new AppSettingsCredentials();
OAuthAccessToken accessToken = await sevenDigitalOAuthProvider.Authenticate(oauthCredentials);
.
Hi @apacha
Just to fill you in, this library is provided to make calls to our api easily with a dotnet app, so a lot of the inner workings/api endpoints are abstracted away. There are some examples in the /examples folder.
var api = new ApiFactory(new ApiUri(), new AppSettingsCredentials());
var requestToken = await api.Create<OAuthRequestToken>()
.Please();
ApiUri
is a basic object that inherits from IApiUri containing the 7digital api url.
e.g.
https://github.com/7digital/SevenDigital.Api.Wrapper/blob/master/examples/ExampleUsage/ExampleUsage/ApiUri.cs
AppSettingsCredentials
is an object inheriting from IOAuthCredentials pointing at somewhere that has access to your api key / secret. e.g:
Details of the web-page where access can be granted is here: http://developer.7digital.com/resources/133
Replace YOUR_KEY_HERE
with your api key, and oauth_token
/ oauth_secret
with the ones returned by the call to the request/token endpoint above.
Finally:
var accessTokenTokenApi = await api.Create<OAuthAccessToken>()
.ForUser(requestToken.Token, requestToken.Secret)
.Please();
I'll try and get this added to the readme, you should be able to find more info in the 7digital Api documentation.
There is an api requesttoken authentication endpoint, which requires a Premium api account to take advantage of.
Hope this helps! Greg
This definitely would have helped a lot if it was included in one of the examples or the documentation or the .NET wrapper! Especially the third part was a pain to implement and obviously can be solved with your API elegantly. Please create another sample which contains exactly these steps, or at least has placeholders for programmers to fill in. (e.g for part two, where a simple HTTP-call has to be made).
The existing samples are just too simple and do not even cover this basic use-case. As for the fluent syntax-API is it really obfuscated, what can and what can't be created, and which parameters are required and which are optional. Especially the call ForUser seems to have multiple undocumented meanings (it takes a request token for creating an access-token and takes an access-token for creating a Locker object).
Thanks for your comments, they have been noted. We'll try and add some better examples soon, but in the mean time free to submit a pull request.
It would be great to provide a complete example of how to use the .NET-Wrapper to perform an OAuth authentication (that seems to be supported but without any samples or descriptions).
I've tried something like
var requestToken = await api.Create<OAuthRequestToken>().Please();
var accessToken = await api.Create<OAuthAccessToken>().WithParameter("oauth_token", requestToken.Token).Please();
but it just keeps throwing "Invalid Signature" exceptions.
I've also read the Guide but so far I wasn't able to obtain a access-token.