Work in progress to re-request permissions. Need to check this in so I can clean the repository. Having some trouble with builds not packaging properly.

This commit is contained in:
Blake Bender 2015-07-13 12:25:52 -07:00
Родитель 7b805f290f
Коммит 326e0357c8
18 изменённых файлов: 206 добавлений и 139 удалений

Просмотреть файл

@ -240,21 +240,54 @@ String^ FacebookDialog::GetFBServer(
return server;
}
#define ScopeKey L"scope"
#define DisplayKey L"display"
#define ResponseTypeKey L"response_type"
#define EqualSign L"="
#define Amp L"&"
#define DefaultScope L"public_profile,email,user_friends"
#define DefaultDisplay L"popup"
#define DefaultResponse L"token"
Uri^ FacebookDialog::BuildLoginDialogUrl(
PropertySet^ Parameters
)
{
FBSession^ sess = FBSession::ActiveSession;
String^ dialogUriString =
L"https://" + GetFBServer() +
L".facebook.com/dialog/oauth?client_id=" + sess->FBAppId +
L"&redirect_uri=" + GetRedirectUriString(L"login") + L"&app_id=" +
sess->FBAppId + L"&scope=" + sess->PermissionsToString() +
L"&display=popup" + L"&response_type=token";
FBSession^ s = FBSession::ActiveSession;
String^ uriString = L"https://" + GetFBServer() +
L".facebook.com/dialog/oauth?client_id=" + s->FBAppId;
DebugPrintLine(L"Request string is " + dialogUriString);
// Use some reasonable default login parameters
String^ scope = DefaultScope;
String^ displayType = DefaultDisplay;
String^ responseType = DefaultResponse;
return ref new Uri(dialogUriString);
uriString += L"&redirect_uri=" + Uri::EscapeComponent(
GetRedirectUriString(L"login")) + L"%2fauth";
// App can pass in parameters to override defaults.
if (Parameters)
{
if (Parameters->HasKey(ScopeKey))
{
scope = (String^)Parameters->Lookup(ScopeKey);
}
if (Parameters->HasKey(DisplayKey))
{
displayType = (String^)Parameters->Lookup(DisplayKey);
}
if (Parameters->HasKey(ResponseTypeKey))
{
responseType = (String^)Parameters->Lookup(ResponseTypeKey);
}
}
uriString += ScopeKey + EqualSign + scope + Amp + DisplayKey + EqualSign +
displayType + Amp + ResponseTypeKey + EqualSign + responseType;
return ref new Uri(uriString);
}
Uri^ FacebookDialog::BuildFeedDialogUrl(

Просмотреть файл

@ -93,19 +93,26 @@ void FBLoginButton::InitWithPermissions(
}
}
void FBLoginButton::SetSessionPermissions(
String^ FBLoginButton::GetPermissions(
)
{
FBSession^ s = FBSession::ActiveSession;
s->ResetPermissions();
String^ permissions = nullptr;
if (m_permissions)
{
IIterator<String^>^ iter = nullptr;
for (iter = m_permissions->First(); iter->HasCurrent; iter->MoveNext())
permissions = ref new String();
for (unsigned int i = 0; i < m_permissions->Size; i++)
{
s->AddPermission(iter->Current);
if (i)
{
permissions += ",";
}
permissions += m_permissions->GetAt(i);
}
}
return permissions;
}
void FBLoginButton::OnClick(
@ -121,9 +128,14 @@ void FBLoginButton::OnClick(
}
else
{
SetSessionPermissions();
String^ permissions = GetPermissions();
PropertySet^ parameters = ref new PropertySet();
if (permissions != nullptr)
{
parameters->Insert(L"scope", permissions);
}
create_task(s->LoginAsync())
create_task(s->LoginAsync(parameters))
.then([=](FBResult^ result)
{
if (result->Succeeded)

Просмотреть файл

@ -76,7 +76,7 @@ namespace Facebook
event ShowingLoggedOutUserHandler^ ShowingLoggedOutUser;
private:
void SetSessionPermissions(
Platform::String^ GetPermissions(
);
void OnClick(

Просмотреть файл

@ -67,10 +67,8 @@ FBSession::FBSession() :
m_loggedIn(false),
m_FBAppId(nullptr),
m_WinAppId(nullptr),
m_permissions(nullptr),
m_user(nullptr)
{
m_permissions = ref new Vector<String^>;
if (!login_evt)
{
login_evt = CreateEventEx(NULL, NULL, 0, DELETE | SYNCHRONIZE);
@ -132,11 +130,6 @@ void FBSession::AccessTokenData::set(FBAccessTokenData^ value)
m_AccessTokenData = value;
}
IVectorView<String^>^ FBSession::Permissions::get()
{
return m_permissions->GetView();
}
Windows::Foundation::DateTime FBSession::Expires::get()
{
return m_Expires;
@ -174,25 +167,8 @@ FBUser^ FBSession::User::get()
return m_user;
}
void FBSession::AddPermission(
String^ permission
)
{
m_permissions->Append(permission);
}
void FBSession::ResetPermissions(
)
{
if (m_permissions)
{
m_permissions->Clear();
}
}
IAsyncAction^ FBSession::Logout()
{
m_permissions->Clear();
m_user = nullptr;
m_FBAppId = nullptr;
m_WinAppId = nullptr;
@ -218,23 +194,6 @@ task<FBResult^> FBSession::GetUserInfo(
return create_task(value->Get());
}
String^ FBSession::PermissionsToString()
{
String^ permissionsString = ref new String();
for (unsigned int i = 0; i < m_permissions->Size; i++)
{
if (i)
{
permissionsString += ",";
}
permissionsString += m_permissions->GetAt(i);
}
return permissionsString;
}
IAsyncOperation<IStorageItem^>^ FBSession::MyTryGetItemAsync(
StorageFolder^ folder,
String^ itemName
@ -494,7 +453,7 @@ Windows::Foundation::IAsyncOperation<FBResult^>^ FBSession::ShowFeedDialog(
}
Windows::Foundation::IAsyncOperation<FBResult^>^ FBSession::ShowRequestsDialog(
Windows::Foundation::Collections::PropertySet^ Parameters
PropertySet^ Parameters
)
{
m_dialog = ref new FacebookDialog();
@ -551,6 +510,7 @@ Windows::Foundation::IAsyncOperation<FBResult^>^ FBSession::ShowRequestsDialog(
}
task<FBResult^> FBSession::ShowLoginDialog(
PropertySet^ Parameters
)
{
m_dialog = ref new FacebookDialog();
@ -637,22 +597,48 @@ task<FBResult^> FBSession::GetAppPermissions(
});
}
#define ScopeKey L"scope"
#define DisplayKey L"display"
#define ResponseTypeKey L"response_type"
#define EqualSign L"="
#define Amp L"&"
Uri^ FBSession::BuildLoginUri(
PropertySet^ Parameters
)
{
String^ uriString = L"https://www.facebook.com/dialog/oauth?client_id=" +
m_FBAppId;
String^ permissionsString = PermissionsToString();
// Use some reasonable default login parameters
String^ scope = L"public_profile,email,user_friends";
String^ displayType = L"popup";
String^ responseType = L"token";
uriString += L"&redirect_uri=" + Uri::EscapeComponent(
GetRedirectUriString()) + L"%2fauth";
if (!permissionsString->IsEmpty())
// App can pass in parameters to override defaults.
if (Parameters)
{
uriString += L"&scope=" + permissionsString;
if (Parameters->HasKey(ScopeKey))
{
scope = (String^)Parameters->Lookup(ScopeKey);
}
if (Parameters->HasKey(DisplayKey))
{
displayType = (String^)Parameters->Lookup(DisplayKey);
}
if (Parameters->HasKey(ResponseTypeKey))
{
responseType = (String^)Parameters->Lookup(ResponseTypeKey);
}
}
uriString += L"&display=popup&response_type=token";
uriString += ScopeKey + EqualSign + scope + Amp + DisplayKey + EqualSign +
displayType + Amp + ResponseTypeKey + EqualSign + responseType;
return ref new Uri(uriString);
}
@ -756,16 +742,17 @@ task<FBResult^> FBSession::TryGetAppPermissionsAfterLogin(
}
task<FBResult^> FBSession::RunOAuthOnUiThread(
PropertySet^ Parameters
)
{
task<void> authTask = create_task(
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(
Windows::UI::Core::CoreDispatcherPriority::Normal,
ref new Windows::UI::Core::DispatchedHandler([this]()
ref new Windows::UI::Core::DispatchedHandler([=]()
{
m_loginTask = create_task(
WebAuthenticationBroker::AuthenticateAsync(
WebAuthenticationOptions::None, BuildLoginUri(),
WebAuthenticationOptions::None, BuildLoginUri(Parameters),
ref new Uri(GetRedirectUriString())))
.then([this](WebAuthenticationResult^ authResult) -> task<FBResult^>
{
@ -802,14 +789,15 @@ task<FBResult^> FBSession::RunOAuthOnUiThread(
}
task<FBResult^> FBSession::RunWebViewLoginOnUIThread(
PropertySet^ Parameters
)
{
task<void> authTask = create_task(
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(
Windows::UI::Core::CoreDispatcherPriority::Normal,
ref new Windows::UI::Core::DispatchedHandler([this]()
ref new Windows::UI::Core::DispatchedHandler([=]()
{
m_loginTask = ShowLoginDialog();
m_loginTask = ShowLoginDialog(Parameters);
})));
return create_task([=](void)
@ -841,6 +829,7 @@ task<FBResult^> FBSession::RunWebViewLoginOnUIThread(
}
IAsyncOperation<FBResult^>^ FBSession::LoginAsync(
PropertySet^ Parameters
)
{
m_dialog = ref new FacebookDialog();
@ -851,11 +840,11 @@ IAsyncOperation<FBResult^>^ FBSession::LoginAsync(
{
FBResult^ result = nullptr;
task<FBResult^> authTask = TryLoginViaWebView();
task<FBResult^> authTask = TryLoginViaWebView(Parameters);
result = authTask.get();
if (!result)
{
authTask = TryLoginViaWebAuthBroker();
authTask = TryLoginViaWebAuthBroker(Parameters);
result = authTask.get();
}
@ -873,6 +862,7 @@ IAsyncOperation<FBResult^>^ FBSession::LoginAsync(
}
task<FBResult^> FBSession::TryLoginViaWebView(
PropertySet^ Parameters
)
{
FBSession^ sess = FBSession::ActiveSession;
@ -901,7 +891,7 @@ task<FBResult^> FBSession::TryLoginViaWebView(
return graphTask;
})
.then([this](FBResult^ graphResult)
.then([=](FBResult^ graphResult)
{
FBResult^ loginResult = nullptr;
@ -911,7 +901,7 @@ task<FBResult^> FBSession::TryLoginViaWebView(
}
else
{
loginResult = RunWebViewLoginOnUIThread().get();
loginResult = RunWebViewLoginOnUIThread(Parameters).get();
}
return loginResult;
@ -919,6 +909,7 @@ task<FBResult^> FBSession::TryLoginViaWebView(
}
task<FBResult^> FBSession::TryLoginViaWebAuthBroker(
PropertySet^ Parameters
)
{
FBSession^ sess = FBSession::ActiveSession;
@ -926,7 +917,7 @@ task<FBResult^> FBSession::TryLoginViaWebAuthBroker(
IAsyncOperation<FBResult^>^ result = nullptr;
return CheckForExistingToken()
.then([this](FBResult^ oauthResult) -> task<FBResult^>
.then([=](FBResult^ oauthResult) -> task<FBResult^>
{
task<FBResult^> graphTask = create_task([]() -> FBResult^
{
@ -949,7 +940,7 @@ task<FBResult^> FBSession::TryLoginViaWebAuthBroker(
return graphTask;
})
.then([this](FBResult^ graphResult)
.then([=](FBResult^ graphResult)
{
task<FBResult^> loginResult;
@ -962,7 +953,7 @@ task<FBResult^> FBSession::TryLoginViaWebAuthBroker(
}
else
{
loginResult = RunOAuthOnUiThread();
loginResult = RunOAuthOnUiThread(Parameters);
}
return loginResult;

Просмотреть файл

@ -81,12 +81,6 @@ namespace Facebook
void set(FBAccessTokenData^ value);
}
//! Returns the list of permissions
property Windows::Foundation::Collections::IVectorView<Platform::String^>^ Permissions
{
Windows::Foundation::Collections::IVectorView<Platform::String^>^ get();
}
//! Expiration date/time of active session
property Windows::Foundation::DateTime Expires
{
@ -100,14 +94,6 @@ namespace Facebook
bool get();
}
//! Request a new permission
void AddPermission(
Platform::String^ permission
);
void ResetPermissions(
);
//! FBSession is a singleton object - ActiveSession is the way to
// acquire a reference to the object.
static property FBSession^ ActiveSession
@ -138,10 +124,8 @@ namespace Facebook
Windows::Foundation::Collections::PropertySet^ Parameters
);
Platform::String^ PermissionsToString(
);
Windows::Foundation::IAsyncOperation<FBResult^>^ LoginAsync(
Windows::Foundation::Collections::PropertySet^ Parameters
);
private:
@ -150,6 +134,7 @@ namespace Facebook
~FBSession();
Windows::Foundation::Uri^ BuildLoginUri(
Windows::Foundation::Collections::PropertySet^ Parameters
);
Platform::String^ GetRedirectUriString(
@ -195,18 +180,23 @@ namespace Facebook
);
concurrency::task<FBResult^> RunOAuthOnUiThread(
Windows::Foundation::Collections::PropertySet^ Parameters
);
concurrency::task<FBResult^> RunWebViewLoginOnUIThread(
Windows::Foundation::Collections::PropertySet^ Parameters
);
concurrency::task<FBResult^> ShowLoginDialog(
Windows::Foundation::Collections::PropertySet^ Parameters
);
concurrency::task<FBResult^> TryLoginViaWebView(
Windows::Foundation::Collections::PropertySet^ Parameters
);
concurrency::task<FBResult^> TryLoginViaWebAuthBroker(
Windows::Foundation::Collections::PropertySet^ Parameters
);
int64 SecondsTilTokenExpires(
@ -218,7 +208,6 @@ namespace Facebook
bool m_loggedIn;
Platform::String^ m_AppResponse;
Facebook::FBAccessTokenData^ m_AccessTokenData;
Platform::Collections::Vector<Platform::String^>^ m_permissions;
Windows::Foundation::DateTime m_Expires;
Facebook::Graph::FBUser^ m_user;
concurrency::task<Facebook::FBResult^> m_loginTask;

Просмотреть файл

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\FBWinSDK-debug.0.9.0\build\FBWinSDK-debug.props" Condition="Exists('..\packages\FBWinSDK-debug.0.9.0\build\FBWinSDK-debug.props')" />
<Import Project="..\packages\FBWinSDK.0.9.0\build\native\FBWinSDK.props" Condition="Exists('..\packages\FBWinSDK.0.9.0\build\native\FBWinSDK.props')" />
<PropertyGroup Label="Globals">
<ProjectGuid>{351701a8-12d1-45b3-8e6a-164d796b0297}</ProjectGuid>
@ -227,5 +228,6 @@
</PropertyGroup>
<Error Condition="!Exists('..\packages\FBWinSDK.0.9.0\build\native\FBWinSDK.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\FBWinSDK.0.9.0\build\native\FBWinSDK.props'))" />
<Error Condition="!Exists('..\packages\FBWinSDK.0.9.0\build\native\FBWinSDK.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\FBWinSDK.0.9.0\build\native\FBWinSDK.targets'))" />
<Error Condition="!Exists('..\packages\FBWinSDK-debug.0.9.0\build\FBWinSDK-debug.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\FBWinSDK-debug.0.9.0\build\FBWinSDK-debug.props'))" />
</Target>
</Project>

Просмотреть файл

@ -91,7 +91,7 @@ void MainPage::login_OnClicked(Platform::Object^ sender, Windows::UI::Xaml::Rout
sess->AddPermission("user_groups");
sess->AddPermission("user_location");
create_task(sess->LoginAsync()).then([=](FBResult^ result)
create_task(sess->LoginAsync(nullptr)).then([=](FBResult^ result)
{
if (result->Succeeded)
{

Просмотреть файл

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FBWinSDK" version="0.9.0" targetFramework="native" userInstalled="true" />
<package id="FBWinSDK-debug" version="0.9.0" targetFramework="native" userInstalled="true" />
</packages>

Просмотреть файл

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
# Visual Studio 14
VisualStudioVersion = 14.0.22823.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "LoginCs", "LoginCs", "{F3A8EFF0-4471-4905-B279-756B1D864AAB}"
EndProject
@ -11,13 +11,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoginCs.Windows", "LoginCs\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoginCs.WindowsPhone", "LoginCs\LoginCs.WindowsPhone\LoginCs.WindowsPhone.csproj", "{EF5F7E3E-8E45-4027-846C-3349247C065D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{3171A043-57BD-4AEE-95F8-56CD3749B615}"
ProjectSection(SolutionItems) = preProject
.nuget\NuGet.Config = .nuget\NuGet.Config
.nuget\NuGet.exe = .nuget\NuGet.exe
.nuget\NuGet.targets = .nuget\NuGet.targets
EndProjectSection
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
LoginCs\LoginCs.Shared\LoginCs.Shared.projitems*{a506e326-7a59-479e-8e80-65fb73ae94d8}*SharedItemsImports = 4

Просмотреть файл

@ -60,7 +60,7 @@ namespace LoginCs
this.Suspending += this.OnSuspending;
}
#if WINDOWS_PHONE_APP
#if FALSE //WINDOWS_PHONE_APP
protected override void OnActivated(IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.Protocol)

Просмотреть файл

@ -33,9 +33,17 @@
<Button x:Name="BackButton" Content="Go Back" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="BackButton_Click"/>
<Button x:Name="UserLikesButton" Content="Show Likes..." HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="UserLikesButton_Click"/>
</StackPanel>
<StackPanel Grid.Row="2" Margin="19,0,0,0">
<Ellipse Width="250" Height="250">
<Ellipse.Fill>
<ImageBrush x:Name="ProfilePicBrush" ImageSource="" />
</Ellipse.Fill>
</Ellipse>
</StackPanel>
<!--TODO: Content should be placed within the following grid-->
<Grid Grid.Row="2" x:Name="ContentRoot" Margin="19,9.5,19,0">
<Grid Grid.Row="3" x:Name="ContentRoot" Margin="19,9.5,19,0">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel Grid.Row="0">
<TextBlock Text="ID:" Style="{ThemeResource TitleTextBlockStyle}" Margin="0,12,0,0"/>

Просмотреть файл

@ -31,6 +31,7 @@ using Windows.UI.Xaml.Navigation;
using Facebook;
using Facebook.Graph;
using Windows.UI.Xaml.Media.Imaging;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
@ -64,9 +65,35 @@ namespace LoginCs
UserUpdatedTime.Text = user.UpdatedTime;
UserVerified.Text = user.Verified.ToString();
SquarePicture.UserId = user.Id;
LoadRoundProfilePicture(user.Id);
}
}
}
private async void LoadRoundProfilePicture(
String UserId
)
{
PropertySet parameters = new PropertySet();
String path = "/" + UserId + "/picture";
parameters.Add(new KeyValuePair<String, Object>("redirect", "false"));
// Just picking a width and height for now
parameters.Add(new KeyValuePair<String, Object>("width", "200"));
parameters.Add(new KeyValuePair<String, Object>("height", "200"));
FBSingleValue value = new FBSingleValue(path, parameters,
new FBJsonClassFactory(FBProfilePicture.FromJson));
FBResult result = await value.Get();
if (result.Succeeded)
{
FBProfilePicture pic = (FBProfilePicture)result.Object;
ProfilePicBrush.ImageSource = new BitmapImage(pic.URL);
}
}
private void UserLikesButton_Click(object sender, RoutedEventArgs e)
{
Frame.Navigate(typeof(UserLikes));

Просмотреть файл

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\packages\FBWinSDK-debug.0.9.0\build\FBWinSDK-debug.props" Condition="Exists('..\..\packages\FBWinSDK-debug.0.9.0\build\FBWinSDK-debug.props')" />
<Import Project="..\..\packages\FBWinSDK.0.9.0\build\win\FBWinSDK.props" Condition="Exists('..\..\packages\FBWinSDK.0.9.0\build\win\FBWinSDK.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
@ -17,9 +18,10 @@
<SynthesizeLinkMetadata>true</SynthesizeLinkMetadata>
<ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<PackageCertificateKeyFile>LoginCs.Windows_TemporaryKey.pfx</PackageCertificateKeyFile>
<NuGetPackageImportStamp>3faccb8c</NuGetPackageImportStamp>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -152,15 +154,17 @@
</Page>
</ItemGroup>
<ItemGroup>
<Reference Include="Facebook">
<HintPath>..\..\packages\FBWinSDK.0.9.0\lib\win\Facebook.winmd</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\netcore45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
<Reference Include="Facebook, Version=255.255.255.255, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\FBWinSDK.0.9.0\lib\win\Facebook.winmd</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.7.0.1\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '12.0' ">
<VisualStudioVersion>12.0</VisualStudioVersion>
@ -169,14 +173,13 @@
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\FBWinSDK.0.9.0\build\win\FBWinSDK.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\FBWinSDK.0.9.0\build\win\FBWinSDK.props'))" />
<Error Condition="!Exists('..\..\packages\FBWinSDK.0.9.0\build\win\FBWinSDK.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\FBWinSDK.0.9.0\build\win\FBWinSDK.targets'))" />
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
<Error Condition="!Exists('..\..\packages\FBWinSDK-debug.0.9.0\build\FBWinSDK-debug.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\FBWinSDK-debug.0.9.0\build\FBWinSDK-debug.props'))" />
</Target>
<Import Project="..\..\packages\FBWinSDK.0.9.0\build\win\FBWinSDK.targets" Condition="Exists('..\..\packages\FBWinSDK.0.9.0\build\win\FBWinSDK.targets')" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

Просмотреть файл

@ -52,8 +52,11 @@ namespace LoginCs
Uri endURI =
WebAuthenticationBroker.GetCurrentApplicationCallbackUri();
string uriString = endURI.ToString();
PropertySet parameters = new PropertySet();
FBResult result = await FBSession.ActiveSession.LoginAsync();
parameters.Add(new KeyValuePair<String, Object>("scope",
"public_profile,email,user_friends,publish_actions"));
FBResult result = await FBSession.ActiveSession.LoginAsync(parameters);
if (result.Succeeded)
{
Frame.Navigate(typeof(UserInfo));
@ -96,13 +99,13 @@ namespace LoginCs
}
}
private void login_OnClicked(object sender, RoutedEventArgs e)
private async void login_OnClicked(object sender, RoutedEventArgs e)
{
FBSession sess = FBSession.ActiveSession;
if (sess.LoggedIn)
{
LoginButton.Content = "Login";
sess.Logout();
await sess.Logout();
//Navigate back to same page, to clear out logged in info.
App.RootFrame.Navigate(typeof(MainPage));
}

Просмотреть файл

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FBWinSDK" version="0.9.0" targetFramework="win81" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="win81" />
<package id="FBWinSDK" version="0.9.0" targetFramework="win81" userInstalled="true" />
<package id="FBWinSDK-debug" version="0.9.0" targetFramework="win81" userInstalled="true" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="win81" userInstalled="true" />
</packages>

Просмотреть файл

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\packages\FBWinSDK-debug.0.9.0\build\FBWinSDK-debug.props" Condition="Exists('..\..\packages\FBWinSDK-debug.0.9.0\build\FBWinSDK-debug.props')" />
<Import Project="..\..\packages\FBWinSDK.0.9.0\build\wpa\FBWinSDK.props" Condition="Exists('..\..\packages\FBWinSDK.0.9.0\build\wpa\FBWinSDK.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
@ -16,9 +17,10 @@
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{76F1466A-8B6D-4E39-A767-685A06062A39};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<SynthesizeLinkMetadata>true</SynthesizeLinkMetadata>
<NuGetPackageImportStamp>f8140d1d</NuGetPackageImportStamp>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -117,14 +119,6 @@
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<Reference Include="Facebook">
<HintPath>..\..\packages\FBWinSDK.0.9.0\lib\wpa\Facebook.winmd</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="..\LoginCs.Shared\FBCSObjectImplementation.ttinclude">
<Link>FBCSObjectImplementation.ttinclude</Link>
@ -142,6 +136,16 @@
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<ItemGroup>
<Reference Include="Facebook, Version=255.255.255.255, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\FBWinSDK.0.9.0\lib\wpa\Facebook.winmd</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.7.0.1\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '12.0' ">
<VisualStudioVersion>12.0</VisualStudioVersion>
</PropertyGroup>
@ -152,14 +156,13 @@
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\FBWinSDK.0.9.0\build\wpa\FBWinSDK.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\FBWinSDK.0.9.0\build\wpa\FBWinSDK.props'))" />
<Error Condition="!Exists('..\..\packages\FBWinSDK.0.9.0\build\wpa\FBWinSDK.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\FBWinSDK.0.9.0\build\wpa\FBWinSDK.targets'))" />
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
<Error Condition="!Exists('..\..\packages\FBWinSDK-debug.0.9.0\build\FBWinSDK-debug.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\FBWinSDK-debug.0.9.0\build\FBWinSDK-debug.props'))" />
</Target>
<Import Project="..\..\packages\FBWinSDK.0.9.0\build\wpa\FBWinSDK.targets" Condition="Exists('..\..\packages\FBWinSDK.0.9.0\build\wpa\FBWinSDK.targets')" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

Просмотреть файл

@ -75,7 +75,7 @@ namespace LoginCs
// Launches a URI to redirect to the FB app, which will log us in
// and return the result via our registered protocol.
await s.LoginAndContinue();
await s.LoginAsync(null);
}
/// <summary>
@ -110,13 +110,13 @@ namespace LoginCs
}
}
private void login_OnClicked(object sender, RoutedEventArgs e)
private async void login_OnClicked(object sender, RoutedEventArgs e)
{
FBSession sess = FBSession.ActiveSession;
if (sess.LoggedIn)
{
LoginButton.Content = "Login";
sess.Logout();
await sess.Logout();
//Navigate back to same page, to clear out logged in info.
App.RootFrame.Navigate(typeof(MainPage));
}

Просмотреть файл

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FBWinSDK" version="0.9.0" targetFramework="wpa81" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="wpa81" />
<package id="FBWinSDK" version="0.9.0" targetFramework="wpa81" userInstalled="true" />
<package id="FBWinSDK-debug" version="0.9.0" targetFramework="wpa81" userInstalled="true" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="wpa81" userInstalled="true" />
</packages>