Reputation: 841
I am using the NuGet Yammer API and I am trying to simply authenticate and display the token as a test.
Unfortunately I can't seem to get it working. I am new to this but there is no documentation on the NuGet Yammer API and it will be a console application. All the examples and documentation on the Yammer developers page show doing this from a web based appication.
My code so far:
static void Main(string[] args)
{
var myConfig = new ClientConfigurationContainer
{
ClientCode = null,
ClientId = "CODEHERE",
ClientSecret = "CODEHERE"
};
var myYammer = new YammerClient(myConfig);
var test = myYammer.GetToken();
Console.WriteLine("Token" + test);
Console.ReadLine();
}
Upvotes: 4
Views: 5248
Reputation: 81
It's an OAuth authentication, you must interact with Yammer OAuth webpage to obtain a token.
You should look in the asp.net mvc example in sources on Github.
In the HomeController.cs :
[HttpPost]
public ActionResult Index(IndexViewModel model)
{
if (ModelState.IsValid)
{
var myConfig = new ClientConfigurationContainer
{
ClientCode = null,
ClientId = model.ClientId,
ClientSecret = model.ClientSecret,
RedirectUri = Request.Url.AbsoluteUri + Url.Action("AuthCode")
};
var myYammer = new YammerClient(myConfig);
// Obtain the URL of Yammer Authorisation Page
var url = myYammer.GetLoginLinkUri();
this.TempData["YammerConfig"] = myConfig;
// Jump to the url page
return Redirect(url);
}
return View(model);
}
And Yammer redirect you here:
public ActionResult AuthCode(String code)
{
if (!String.IsNullOrWhiteSpace(code))
{
var myConfig = this.TempData["YammerConfig"] as ClientConfigurationContainer;
myConfig.ClientCode = code;
var myYammer = new YammerClient(myConfig);
// var yammerToken = myYammer.GetToken();
// var l = myYammer.GetUsers();
// var t= myYammer.GetImpersonateTokens();
// var i = myYammer.SendInvitation("[email protected]");
// var m = myYammer.PostMessage("A test from here", 0, "Event");
return View(myYammer.GetUserInfo());
}
return null;
}
Upvotes: 3
Reputation: 2022
The person who wrote the API also wrote an article on how to use it, which is here:
http://fullsaas.blogspot.fr/2013/05/a-simple-net-wrapper-of-yammer-api.html
This may also be useful:
Upvotes: 2