Begins a RedCritter user session. This session is valid for both end user and management API calls where applicable.
This signs a user into the RedCritter system and establishes a SessionID
https://redcritterconnecter.com/services/management/SignIn?emailOrUserName={emailOrUserName}&password={password}&invitationAppDomainID={InvitationAppDomainID}&InvitationCode={InvitationCode}&ShareCode={ShareCode}&getProfile={getProfile}&developerLogin={developerLogin}&sessionTimeOutMin={sessionTimeoutMin}
EmailOrUsername | string | yes | The email address or the RedCritter username. |
Password | string | yes | The password of the RedCritter user. |
InvitationAppDomainID | int64 | no | The App Domain ID to use. |
InvitationCode | string | no | The Invitation Code to use. |
ShareCode | string | no | The Share Code to use. |
GetProfile | bool | no | Determines wether or not to retrieve the user's full profile upon successful login. |
DeveloperLogin | bool | no | Determines if the user is logging in as a developer or a normal user. |
SessionTimeoutMin | int32 | no | Set the minimum timeout interval. |
Code Samples Javascript, C#, PHP
SignIn with JavaScript
This is a minimal example of calling the AddAction API via HTML and Javascript. Remember to never use your Secret Keys on the client side.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.js"></script>
<style type='text/css'>
body {
font-family: "Arial";
}
.rctable{
padding-top:20px;
padding-bottom:10px;
border-bottom:solid 1px #ccc;
width:600px;
}
.rclabel {
font-size:14px;
font-weight:bold;
}
.rcval{
font-size:14px;
padding-left:10px;
}
</style>
<script type="text/javascript">
var connecterURL = "https://www.redcritterconnecter.com/";
function signIn(emailOrUsername, password, invitationAppDomainID, invitationCode, shareCode, getProfile, developerLogin, sessionTimeoutMin, cbSuccess, cbFail) {
$.getJSON(connecterURL + "services/management/signIn?jsoncallback=?", { emailOrUsername: emailOrUsername, password: password, invitationAppDomainID:invitationAppDomainID, invitationCode: invitationCode, shareCode: shareCode, getProfile: getProfile, developerLogin: developerLogin, sessionTimeoutMin: sessionTimeoutMin },
function (data) {
if (data.Result) {
cbSuccess(data);
} else {
cbFail(data);
}
});
}
//My Success Callback
function onMysignInSuccessHandler(data) {
//data is JSON response
renderItems(data)
}
//My Failure Callback
function onMysignInFailHandler(data) {
//Something went wrong
alert("Something went wrong");
}
//Sample function to generate the list output in html
function renderItems(data) {
var h = "";
var h = "<table class='rctable'>";
h += "<tr><td class='rclabel'>SessionID : </td><td class='rcval'>" + HTMLEncode(data.SessionID) + "</td></tr>"
h += "<tr><td class='rclabel'>UserID: </td><td class='rcval'>" + HTMLEncode(data.UserID) + "</td></tr>"
h += "</table>";
$("#results").html(h);
//display the results
$("#results").html(h);
}
function HTMLEncode(str) {
var div = document.createElement('div');
var text = document.createTextNode(str);
div.appendChild(text);
return div.innerHTML;
}
</script>
</head>
<body>
<table>
<tr>
<td>Email or Username</td>
<td>
<input type="text" id="tEmailOrUsername" style="width: 500px" />
</td>
</tr>
<tr>
<td>password</td>
<td>
<input type="text" id="tPassword" style="width: 500px" />
</td>
</tr>
<tr>
<td>Invitation App Domain ID (Default 0)</td>
<td>
<input type="text" id="tInvitationAppDomainID" style="width: 500px" />
</td>
</tr>
<tr>
<td>Invitation Code (Default Null)</td>
<td>
<input type="text" id="tInvitationCode" style="width: 500px" />
</td>
</tr>
<tr>
<td>Share Code (Default Null)</td>
<td>
<input type="text" id="tShareCode" style="width: 500px" />
</td>
</tr>
<tr>
<td>Get Profile? (Default false)</td>
<td>
<input type="text" id="tGetProfile" style="width: 500px" />
</td>
</tr>
<tr>
<td>Developer Login? (Default false)</td>
<td>
<input type="text" id="tDeveloperLogin" style="width: 500px" />
</td>
</tr>
<tr>
<td>Session Timeout Min (Default 720)</td>
<td>
<input type="text" id="tSessionTimeoutMin" style="width: 500px" />
</td>
</tr>
<tr>
<td></td>
<td>
<input type="button" onclick="signIn($('#tEmailOrUsername').val(), $('#tPassword').val(), $('#tInvitationAppDomainID').val(), $('#tInvitationCode').val(), $('#tShareCode').val(), $('#tGetProfile').val(), $('#tDeveloperLogin').val(), $('#tSessionTimeoutMin').val(), onMysignInSuccessHandler, onMysignInFailHandler)" value="Login to RedCritter" /></td>
</tr>
</table>
<br />
<div id="results"></div>
</body>
</html>
SignIn with C#
This is a minmal example of calling the SignIn API and parsing the JSON result into a populated C# object. This example uses asynchronous techniques to raise a callback when the response is received.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.IO;
using System.Web; //Add reference to System.Web
using System.Runtime.Serialization.Json; //Add reference to System.Runtime.Serialization
namespace RedCritterConnecter.Samples
{
//Create a class to contain the response
public class SignInResponse
{
public String SessionID { get; set; }
public String UserID { get; set; }
public Boolean Result { get; set; }
}
public class SignIn
{
public delegate void OnSignInResponse(SignInResponse SignInResponse);
public event OnSignInResponse onSignInResponse;
public delegate void OnSignInResponseError(SignInResponse SignInResponse);
public event OnSignInResponseError onSignInResponseError;
const string CONST_ConnecterBaseURL = "https://www.redcritterconnecter.com/";
public void Execute(String EmailOrUsername, String Password, String InvitationAppDomainID, String InvitationCode, String ShareCode, String GetProfile, String DeveloperLogin, String SessionTimeoutMin)
{
try
{
//Create url encoded parameters in query string
String queryString = "emailorusername=" + System.Web.HttpUtility.UrlEncode(EmailOrUsername) + "&password=" + System.Web.HttpUtility.UrlEncode(Password) + "&invitationappdomainid=" + System.Web.HttpUtility.UrlEncode(InvitationAppDomainID) + "&invitationcode='" + System.Web.HttpUtility.UrlEncode(InvitationCode) + "'&sharecode='" + System.Web.HttpUtility.UrlEncode(ShareCode) + "'&getprofile=" + System.Web.HttpUtility.UrlEncode(GetProfile) + "&developerlogin=" + System.Web.HttpUtility.UrlEncode(DeveloperLogin) + "&sessiontimeoutmin=" + System.Web.HttpUtility.UrlEncode(SessionTimeoutMin);
//Create a new instance of a WebClient
WebClient wc = new System.Net.WebClient();
//Prevent this request from caching in order to ensure that it is sent to server
wc.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
//Attach an event handler to receive the response
wc.DownloadStringCompleted += onSignInResponseReceived;
//Make the call
wc.DownloadStringAsync(new Uri(CONST_ConnecterBaseURL + "services/management/SignIn?" + queryString, UriKind.Absolute));
}
catch
{
//Something went wrong communicating with the server
if (onSignInResponseError != null)
{
onSignInResponseError(null);
}
}
}
private void onSignInResponseReceived(object sender, DownloadStringCompletedEventArgs e)
{
try
{
//Create a JSON serializer
System.Runtime.Serialization.Json.DataContractJsonSerializer s = new DataContractJsonSerializer(typeof(SignInResponse));
//Copy the string into a memory stream
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(e.Result));
//Read the stream into an object matching the response's type
SignInResponse SignInResponse = (SignInResponse)s.ReadObject(ms);
//Work with the populated response object
if (SignInResponse.Result == true)
{
//Request was accepted, raise the success event
onSignInResponse(SignInResponse);
}
else
{
//Something went wrong
if (onSignInResponseError != null)
{
//Request failed, raise the error event
onSignInResponseError(SignInResponse);
}
}
}
catch
{
//Something went wrong
onSignInResponseError(null);
}
}
}
}
PHP Snippet using SignIn
Here's a PHP snippet that retrieves a user's sessionID and turns it into a Javascript variable. This can be embedded in any HTML page but requires a .PHP extension (and PHP support)
<script type="text/javascript">
<?php
$emailOrUsername = '{UserEmailOrUsername}';
$password = '{UserPassword}';
$jsonurl = 'https://redcritterconnecter.com/services/management/SignIn?emailOrUserName='. $emailOrUsername .'&password='. $password;
$json = file_get_contents($jsonurl);
$json_output = json_decode($json);
if ($json_output->Result) {
$SessionID = $json_output->SessionID;
echo 'var sessionID = "'. $SessionID .'";'. "\n";
} else {
echo 'var sessionID = "";'. "\n";
}
?>
</script>
Responses JSON, XML
JSON Response
{
"SessionID": "7c1c2381-c825-4717-bb93-47daa643c32f459d8bea-4e79-41ba-b7ba-b0ed67edd942",
"UserID": 135,
"StorageAccountName": "",
"Result": true,
"ResultTitle": "",
"ResultMessage": "",
"ActivationEmail": "",
"ShareCode": "\"\"",
"UserProfileResponse": {
"RootImageURL": "",
"AboutMe": "",
"AskMeAbout": "",
"FirstName": "",
"LastName": "",
"Username": null,
"UserID": 0,
"PersonalEmail": "",
"WorkEmail": "",
"Company": "",
"Title": "",
"MobilePhone": "",
"HomePhone": "",
"WorkPhone": "",
"IconURL": "",
"MuralImageURL": "",
"MuralOpacity": 1.0,
"BackgroundImageURL": "",
"BackgroundLayout": "s",
"BackgroundColor": "#000",
"PublicKey": "",
"AnalyticsCode": "",
"Apps": [],
"Favorites": [],
"FeedItems": [],
"Links": [],
"Accolades": [],
"Settings": [],
"Version": 0,
"VersionApps": 0,
"VersionAppDomains": 0,
"VersionProfile": 0,
"VersionAccolades": 0,
"VersionBadges": 0,
"VersionCerts": 0,
"VersionLeaderboards": 0,
"VersionSkills": 0,
"VersionRewards": 0,
"VersionFeed": 0,
"Result": false,
"ResultTitle": "",
"ResultMessage": ""
}
}
XML Response
<Response xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="Connecter">
<ActivationEmail />
<Result>true</Result>
<ResultMessage />
<ResultTitle />
<SessionID>
24e039e9-00f4-483e-8bd6-2952ac462f264efbc7ed-1c2a-4a4c-8b9f-43d8ce639ed3
</SessionID>
<ShareCode>""</ShareCode>
<StorageAccountName />
<UserID>135</UserID>
<UserProfileResponse>
<AboutMe />
<Accolades />
<AnalyticsCode />
<Apps />
<AskMeAbout />
<BackgroundColor>#000</BackgroundColor>
<BackgroundImageURL />
<BackgroundLayout>s</BackgroundLayout>
<Company />
<Favorites />
<FeedItems />
<FirstName />
<HomePhone />
<IconURL />
<LastName />
<Links />
<MobilePhone />
<MuralImageURL />
<MuralOpacity>1</MuralOpacity>
<PersonalEmail />
<PublicKey />
<Result>false</Result>
<ResultMessage />
<ResultTitle />
<RootImageURL />
<Settings />
<Title />
<UserID>0</UserID>
<Username i:nil="true" />
<Version>0</Version>
<VersionAccolades>0</VersionAccolades>
<VersionAppDomains>0</VersionAppDomains>
<VersionApps>0</VersionApps>
<VersionBadges>0</VersionBadges>
<VersionCerts>0</VersionCerts>
<VersionFeed>0</VersionFeed>
<VersionLeaderboards>0</VersionLeaderboards>
<VersionProfile>0</VersionProfile>
<VersionRewards>0</VersionRewards>
<VersionSkills>0</VersionSkills>
<WorkEmail />
<WorkPhone />
</UserProfileResponse>
</Response>
|
Use |
Configuration |
Method |
HTTP GET |
Invites User |
No |
Billable |
No |
Response |
JSON,XML |
API Version |
1 |
|