Obtaining Authentication using Blackbaud Sky API with C# Web Application
I feel a bit dumb asking this question, but I've gone through as many of the reference resources available on the site, and I'm having trouble figuring out how to request a subscription key from Blackbaud OAuth 2.0 Service from my application? When I use the web based API ("Try it") I can select Authorization code and the subscription key field is then populated with a code that I'm able to paste into my application and use for an hour. But I know there must be a way to request that using the SKY API.
I'm just trying to build a simple donation website for our organization. Again the application works fine when I obtain the subscription key manually, and I get the data response that I'm looking for, but I just don't know how to request it dynamically in my code. Could someone please point me in the right direction? I've lost so much time on my project trying to figure this out, and it's time to humble my self and request the support of others.
Thank you so much for your help. If you have any questions that require clarification, please let me know and I'll be glad to provide it.
Rob
I'm just trying to build a simple donation website for our organization. Again the application works fine when I obtain the subscription key manually, and I get the data response that I'm looking for, but I just don't know how to request it dynamically in my code. Could someone please point me in the right direction? I've lost so much time on my project trying to figure this out, and it's time to humble my self and request the support of others.
Thank you so much for your help. If you have any questions that require clarification, please let me know and I'll be glad to provide it.
Rob
1
Comments
-
Hi Robert,
You may have already checked out the SKY authorization documentation, but if not, that is the place to start.
Your subscription keys are available from Developer account/My subscriptions. (I assume you have access to https://developer.blackbaud.com/subscriptions.)
But what I think you're really after is the authorization code flow which will result in you having a renewable token set (Refresh and Access tokens) that you can use to make API calls.
This is where I think you might need to (re)visit the documentation.
You can also grab a copy of our SKYLib•NET API Library and SDK. SKYLib makes the whole development process much easier and faster - you can literally have an app up and running in a few minutes. And it also includes a couple of ready-made demonstration applications - one in VB.NET, the other in C#.NET - which you can use as a base to kick off your own app. The demonstration apps can also serve to simply obtain/renew your authorization tokens. And you can use the whole thing free-of-charge in call-rate limited (1 call/s) mode which might be all you need. (A subscription unlocks the full speed call rate of up to 10 call/s.)
I hope that helps.
Cheers,
Steve Cinquegrana | CEO and Principal Developer | Protégé Solutions
0 -
Figured it out... Here's a working example for the next person trying to figure this out.
var url = "https://oauth2.sky.blackbaud.com/token";
var httpRequest = (HttpWebRequest)WebRequest.Create(url);
httpRequest.Method = "POST";
httpRequest.Headers["Authorization"] = "Basic <Your Code>";
httpRequest.ContentType = "application /x-www-form-urlencoded";
var data = "grant_type=authorization_code&redirect_uri=" + redirect_uri + "&code=" + retCode;
using (var streamWriter = new StreamWriter(httpRequest.GetRequestStream()))
{
streamWriter.Write(data);
}
try
{
var httpResponse = (HttpWebResponse)httpRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
token = JsonConvert.DeserializeObject<CToken>(result);
}
}
catch (Exception ex)
{
ViewBag.Error = ex.Message;
}
}1
Categories
- All Categories
- 6 Blackbaud Community Help
- 206 bbcon®
- 1.4K Blackbaud Altru®
- 394 Blackbaud Award Management™ and Blackbaud Stewardship Management™
- 1.1K Blackbaud CRM™ and Blackbaud Internet Solutions™
- 15 donorCentrics®
- 358 Blackbaud eTapestry®
- 2.5K Blackbaud Financial Edge NXT®
- 646 Blackbaud Grantmaking™
- 561 Blackbaud Education Management Solutions for Higher Education
- 3.2K Blackbaud Education Management Solutions for K-12 Schools
- 934 Blackbaud Luminate Online® and Blackbaud TeamRaiser®
- 84 JustGiving® from Blackbaud®
- 6.4K Blackbaud Raiser's Edge NXT®
- 3.6K SKY Developer
- 242 ResearchPoint™
- 118 Blackbaud Tuition Management™
- 165 Organizational Best Practices
- 238 The Tap (Just for Fun)
- 33 Blackbaud Community Challenges
- 28 PowerUp Challenges
- 3 (Open) Raiser's Edge NXT PowerUp Challenge: Product Update Briefing
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Standard Reports+
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Email Marketing
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Gift Management
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Event Management
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Home Page
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Standard Reports
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Query
- 778 Community News
- 2.9K Jobs Board
- 53 Blackbaud SKY® Reporting Announcements
- 47 Blackbaud CRM Higher Ed Product Advisory Group (HE PAG)
- 19 Blackbaud CRM Product Advisory Group (BBCRM PAG)