How to get the current session details in windows phone 8 when using Facebook ,Google and Microsoft login

I want to get the session details like access token , provider etc on a page (ExamplePage.xaml.cs) , i used the following example from nokia developers community (link)
 and implemented the login part but how can i get session details  so that i can send it to my API
The SessionService class manages the session on facebook,google,microsoft login:
/// <summary>
/// The service session.
/// </summary>
public class SessionService : ISessionService
private readonly IApplicationSettingsService _applicationSettings;
private readonly IFacebookService _facebookService;
private readonly IMicrosoftService _microsoftService;
private readonly IGoogleService _googleService;
private readonly ILogManager _logManager;
/// <summary>
/// Initializes a new instance of the <see cref="SessionService" /> class.
/// </summary>
/// <param name="applicationSettings">The application settings.</param>
/// <param name="facebookService">The facebook service.</param>
/// <param name="microsoftService">The microsoft service.</param>
/// <param name="googleService">The google service.</param>
/// <param name="logManager">The log manager.</param>
public SessionService(IApplicationSettingsService applicationSettings,
IFacebookService facebookService,
IMicrosoftService microsoftService,
IGoogleService googleService, ILogManager logManager)
_applicationSettings = applicationSettings;
_facebookService = facebookService;
_microsoftService = microsoftService;
_googleService = googleService;
_logManager = logManager;
/// <summary>
/// Gets the session.
/// </summary>
/// <returns>The session object.</returns>
public Session GetSession()
var expiryValue = DateTime.MinValue;
string expiryTicks = LoadEncryptedSettingValue("session_expiredate");
if (!string.IsNullOrWhiteSpace(expiryTicks))
long expiryTicksValue;
if (long.TryParse(expiryTicks, out expiryTicksValue))
expiryValue = new DateTime(expiryTicksValue);
var session = new Session
AccessToken = LoadEncryptedSettingValue("session_token"),
Id = LoadEncryptedSettingValue("session_id"),
ExpireDate = expiryValue,
Provider = LoadEncryptedSettingValue("session_provider")
_applicationSettings.Set(Constants.LoginToken, true);
_applicationSettings.Save();
return session;
/// <summary>
/// The save session.
/// </summary>
/// <param name="session">
/// The session.
/// </param>
private void Save(Session session)
SaveEncryptedSettingValue("session_token", session.AccessToken);
SaveEncryptedSettingValue("session_id", session.Id);
SaveEncryptedSettingValue("session_expiredate", session.ExpireDate.Ticks.ToString(CultureInfo.InvariantCulture));
SaveEncryptedSettingValue("session_provider", session.Provider);
_applicationSettings.Set(Constants.LoginToken, true);
_applicationSettings.Save();
/// <summary>
/// The clean session.
/// </summary>
private void CleanSession()
_applicationSettings.Reset("session_token");
_applicationSettings.Reset("session_id");
_applicationSettings.Reset("session_expiredate");
_applicationSettings.Reset("session_provider");
_applicationSettings.Reset(Constants.LoginToken);
_applicationSettings.Save();
/// <summary>
/// The login async.
/// </summary>
/// <param name="provider">
/// The provider.
/// </param>
/// <returns>
/// The <see cref="Task"/> object.
/// </returns>
public async Task<bool> LoginAsync(string provider)
Exception exception = null;
try
Session session = null;
switch (provider)
case Constants.FacebookProvider:
session = await _facebookService.LoginAsync();
break;
case Constants.MicrosoftProvider:
session = await _microsoftService.LoginAsync();
break;
case Constants.GoogleProvider:
session = await _googleService.LoginAsync();
break;
if (session != null)
Save(session);
return true;
catch (InvalidOperationException e)
throw;
catch (Exception ex)
exception = ex;
await _logManager.LogAsync(exception);
return false;
/// <summary>
/// The logout.
/// </summary>
public async void Logout()
Exception exception = null;
try
var session = GetSession();
switch (session.Provider)
case Constants.FacebookProvider:
_facebookService.Logout();
break;
case Constants.MicrosoftProvider:
_microsoftService.Logout();
break;
case Constants.GoogleProvider:
_googleService.Logout();
break;
CleanSession();
catch (Exception ex)
exception = ex;
if (exception != null)
await _logManager.LogAsync(exception);
/// <summary>
/// Loads an encrypted setting value for a given key.
/// </summary>
/// <param name="key">
/// The key to load.
/// </param>
/// <returns>
/// The value of the key.
/// </returns>
private string LoadEncryptedSettingValue(string key)
string value = null;
var protectedBytes = _applicationSettings.Get<byte[]>(key);
if (protectedBytes != null)
byte[] valueBytes = ProtectedData.Unprotect(protectedBytes, null);
value = Encoding.UTF8.GetString(valueBytes, 0, valueBytes.Length);
return value;
/// <summary>
/// Saves a setting value against a given key, encrypted.
/// </summary>
/// <param name="key">
/// The key to save against.
/// </param>
/// <param name="value">
/// The value to save against.
/// </param>
/// <exception cref="System.ArgumentOutOfRangeException">
/// The key or value provided is unexpected.
/// </exception>
private void SaveEncryptedSettingValue(string key, string value)
if (!string.IsNullOrWhiteSpace(key) && !string.IsNullOrWhiteSpace(value))
byte[] valueBytes = Encoding.UTF8.GetBytes(value);
// Encrypt the value by using the Protect() method.
byte[] protectedBytes = ProtectedData.Protect(valueBytes, null);
_applicationSettings.Set(key, protectedBytes);
_applicationSettings.Save();

I need to get the session details in the following page AllEvents.xaml.cs  :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using AuthenticationSample.WP80.ViewModel;
using AuthenticationSample.WP80.Services.Model;
using AuthenticationSample.WP80.Services;
using AuthenticationSample.WP80.Resources;
using System.Threading.Tasks;
namespace AuthenticationSample.WP80.Views
public partial class AllEvents : PhoneApplicationPage
public AllEvents()
InitializeComponent();
MainViewModels FakeData = new MainViewModels();
FakeData.LoadData();
DataContext = FakeData;

Similar Messages

  • HT204409 Can someone please help me.....I am trying to find out how you get the pass word for joining a Wi-Fi when asked to join and then told to put in a password. How do you get that?

    ok

    Thank you roaminggnome. All that I don't know. I know nothing about all this stuff. I am on a pc here at home that has a cable hookup to Roadrunner internet. Some kind of modome with a buch of lights sit on top of my computer that hooks me up. So I don't guess I have wi-fi here. Ever since I got my iphone 4, I have been trying to use FaceTime here and it always tell me that I need a wi-fi connection I think. Also wanted to update to iso5 again it tells me the same. Every now and then a thing will pop up on my phone asking if I want to join a certain Wi-Fi that has the littlck on it and when I click join it tells me to put in the pass word to join. NO GO! Thanks again for your help. I do appreciate it. I guess I will have to find someone that lives around me that can explain this stuff to me and show me what is needed.

  • Get the current session in a Session Bean?

    Hi,
    I know how to get the current session from a Servlet, you use request.getSession().
    However I need access to the current session from a Session Bean. As far as I know, only Servlets have a request object, so I can't use request.getSession()
    Any ideas on how to access the session from a Session Bean?
    Thanks!

    Hi,
    I managed to get around the problem by using a JSP to
    pass a session object to a method in my session bean.
    ThanksJust be aware that the serialized Session object can be a huge stream to remotely pass to your bean...
    Kexkey

  • How to get the current page URL

    HI All
    I am working in oracle apps 4.0
    I have one page called history in that i have one page item called Application url. My application id is 122 but its a copy of application 106
    How to get the current page url for the page item.
    Any steps should be help ful
    Thanks & Regards
    Srikkanth.M

    I'm not 100% clear on what the requirement is from the description, however it does sound like you are making things unnecessarily complicated.
    If you want permanent/ID-independent links then use application and page aliases.
    so here we used to display the url like this: <tt>{noformat}http://81.131.254.171:8080/apex/f?p=122{noformat}</tt>
    Do you mean that the URL is displayed like that? If so that doesn't seem particularly helpful. How is anyone supposed to know what it is?
    There are many ways to provide links in APEX&mdash;including lists and nav bars.
    Where the link is to another resource located on the same server (such as another page in the same app, or a different app in the workspace), relative addressing can be used, making it unecessary to include scheme, domain and port information in the URL. For example, if the page to be linked to has a page alias <tt>ABOUT</tt> in an application with alias <tt>UNITY</tt>, and the apps share an authentication scheme/cookie to permit shared sessions, then the link URL is simply
    f?p=UNITY:ABOUT:&APP_SESSION.

  • How to get the current user logon to portal?

    Hi Gurus,
    How to get the current user who logged into portal.
    I have a webdynpro requirement where in which I have to get the current user id who loggedinto portal which will be the input parameter of the BAPI(adaptive RFC model) which will return me employee number of the particular user.
    Can anyone send me the code to retrive the user id through webdynpro application..........
    Pts will be rewarded for useful inputs......
    Thanks in Advance,
    Dharani

    Hi Dharani,
    Using UMEfactory u can do that...
    1. create one input field,
    2. create one attribute called Uid
    3. assign Uid attribute to the input field
    4. type the following code in Doinit() method
                String uid = wdContext.currentContextElement().getUid();
         try {
         IUser user = UMFactory.getUserFactory().
         getUserByLogonID(uid);
         String userName = user.getDisplayName();
         } catch (UMException ex) {
          e.toString(); 
    5. after that go to Portal create one iview assign to particular user. then u get into the user details...
    thats it
    Regards,
    P.Manivannan

  • How to get the current path of my application in java ?

    how to get the current path of my application in java ?
    thanks

    To get the path where your application has been installed you have to do the following:
    have a class called "what_ever" in the folder.
    then you do a litte:
    String path=
    what_ever.class.getRessource("what_ever.class").toString()
    That get you a string like:
    file:/C:/Program Files/Cool_program/what_ever.class
    Then you process the result a little to remove anything you don't want:
    path=path.substring(path.indexOf('/')+1),path.lastIndexOf('/'))
    //Might be a little error here but you should find out //quickly if it's the case
    And here you go, you have a nice
    C:/Program Files/Cool_program
    which is the path to your application.
    Hooray

  • How to get the "current date" in the BEx?

    Hi all,
    I need to get the "current date" in my Bex report in order to make a comparison. I know there is a "How to" which shows how to get the current date via a User Exit, but I didn't find it. Could you please help me?
    Thanks

    1. Create a  New Formula in Key Figures structure
    2. Give tech name and description and Select "New variable" option
    3. Next screen will launch Variable Wizard -> create a new variable with replacement path as processing type
    4. in next screene  select the date characteristic that represents the first date to use in the calculation (From Date)
    5. In the next  screen select Key in the Replace Variable with field. Leave all the other options as they are
    6. In the next Currencies and Units screen select Date as the Dimension ID.
    6. Save variable
    repeate the Above steps to create another variable (To Date)
    and now you can use these two new replacement path variables in your new formula.
    Dev

  • How to get the current logical system?

    Dear Abapers:
    I can't find the logical system value from the table SYST, pls tell me how to get the current logical system name, Thanks!

    Hi,
    Check with the table T000, the Logical system field name is LOGSYS.
    Regards
    Thiru

  • How to get the current transaction variant ?

    dear guru,
    could you please tell me how to get the current transaction variant?
    i tried the following method:
      DATA l_tcvariant TYPE tcvariant.
      CALL 'DY_GET_TX_VARIANT'
         ID 'VARIANT' FIELD l_tcvariant.
    but it failed.
    best regards.
    zj

    Try something like this
    DATA:  VARIANT LIKE SHDTVCIU-TCVARIANT.
      CLEAR VARIANT.
      CALL FUNCTION 'RS_HDSYS_GET_TC_VARIANT'
       IMPORTING
         TCVARIANT                     = VARIANT
    *     FLAG_CLIENT_INDEPENDENT       =
    *     RC                            =
    *   TABLES
    *     T_SCREEN_VARIANTS             =
    *     T_INACTIVE_FUNCTIONS          =

  • How to get the Current User on the UI page?

    All,
    Could you please let me know how to get the Current user on the UI input page , i need to display the current user ID when some one clicks the submit button, i want o get the current user to display in the javascript alert box.
    Edited by: 951930 on Oct 24, 2012 12:21 PM

    lucky,
    my schema has already defined for
    <user mapField="USER_ID" default="%CurrentUser"/>
    and in my UI page
    <td oraLabel="user"></td><td oraField="user" id="userId" ></td>
    and my javascript
    function showUserId () {                        
    var curUser = document.getElementById('userId').value;
    alert(curUser);
    and i have called this function on my submit button, but i am not able to get Current Logged User ID value to show in the alert nor able to show the current logged user on the UI page.
    my requirement is on custom UI page i need to show Current Logged User in one corner of the page and also need to show the same user in alert when he submits the button.
    Appreciate for the help.
    Edited by: 951930 on Oct 25, 2012 8:42 AM
    Edited by: 951930 on Oct 25, 2012 9:06 AM

  • How to get the current week from sysdate?

    Hi sir,
    i want to know how to get the current week from sysdate?
    thanks

    Hi Nicolas
    It seems you like to check my post and also make commend ;) thanks for your attention
    Have you ever read the posts above and given solutions ?Yes, I did
    Have you read the docs ? Yes, I checked
    What's the added value here ?Did youYou shared doc with solution(long one), I shared short one which point same solution(Check what Joel posted)..So what is benefit, As you can guess oracle docs are sometimes become so complicated as specialy for beginner...(At least it was like that for me and Belive me somedocs are still sooo complicated even for oracle coworkers ) But for you I dont know ;)
    => Why writting the PS in bold ?Why.. Let me think... Ohh Maybe I am looking some questions(many) and even user get answer they should not changed status so I am reading some posts and try to get problem and loosing time..
    So I am putting that PS wiht BOLD because I dont wanna lose time my friend ;) Because While I am trying to help ppl here In same time I am trying to giving support to my customer prod systems. Which mean time is very important for me...
    Hope my answer could satisfy you..
    One important PS for you.. You may not like my posts (or someone) but my friend I become tired to read&answer and make commend to on your comment which is about my posts.
    I am not newbie in forum(At least I fell like that) and I belive I know how I should make post..
    Thank you
    Regards
    Helios

  • How to get the current schema name

    Hi,
    Can anybody please tell me how to get the current schema name, there is some inbuilt function for this,but i am not getting that. Please help me.
    Thanks
    Jogesh

    ok folks, I found the answer at Tom's as usual.
    http://asktom.oracle.com/tkyte/who_called_me/index.html
    I rewrote it into a function for kicks. just pass the results of DBMS_UTILITY.FORMAT_CALL_STACK to this function and you will get back the owner of the code making the call as well some extra goodies like the name of the code and the type of code depending on the parameter. This ignores the AUTHID CURRENT_USER issues which muddles the schemaid. Quick question, does the average user always have access to DBMS_UTILITY.FORMAT_CALL_STACK or does this get locked down on some systems?
    cheers,
    paul
    create or replace
    FUNCTION SELF_EXAM (
       p_call_stack VARCHAR2,
       p_type VARCHAR2 DEFAULT 'SCHEMA'
    ) RETURN VARCHAR2
    AS
       str_stack   VARCHAR2(4000);
       int_n       PLS_INTEGER;
       str_line    VARCHAR2(255);
       found_stack BOOLEAN DEFAULT FALSE;
       int_cnt     PLS_INTEGER := 0;
       str_caller  VARCHAR2(30);
       str_name    VARCHAR2(30);
       str_owner   VARCHAR2(30);
       str_type    VARCHAR2(30);
    BEGIN
       str_stack := p_call_stack;
       -- Loop through each line of the call stack
       LOOP
         int_n := INSTR( str_stack, chr(10) );
         EXIT WHEN int_cnt = 3 OR int_n IS NULL OR int_n = 0;
         -- get the line
         str_line := SUBSTR( str_stack, 1, int_n - 1 );
         -- remove the line from the stack str
         str_stack := substr( str_stack, int_n + 1 );
         IF NOT found_stack
         THEN
            IF str_line like '%handle%number%name%'
            THEN
               found_stack := TRUE;
            END IF;
         ELSE
            int_cnt := int_cnt + 1;
             -- cnt = 1 is ME
             -- cnt = 2 is MY Caller
             -- cnt = 3 is Their Caller
             IF int_cnt = 1
             THEN
                str_line := SUBSTR( str_line, 22 );
                dbms_output.put_line('->' || str_line);
                IF str_line LIKE 'pr%'
                THEN
                   int_n := LENGTH('procedure ');
                ELSIF str_line LIKE 'fun%'
                THEN
                   int_n := LENGTH('function ');
                ELSIF str_line LIKE 'package body%'
                THEN
                   int_n := LENGTH('package body ');
                ELSIF str_line LIKE 'pack%'
                THEN
                   int_n := LENGTH('package ');
                ELSIF str_line LIKE 'anonymous%'
                THEN
                   int_n := LENGTH('anonymous block ');
                ELSE
                   int_n := null;
                END IF;
                IF int_n IS NOT NULL
                THEN
                   str_type := LTRIM(RTRIM(UPPER(SUBSTR( str_line, 1, int_n - 1 ))));
                 ELSE
                   str_type := 'TRIGGER';
                 END IF;
                 str_line  := SUBSTR( str_line, NVL(int_n,1) );
                 int_n     := INSTR( str_line, '.' );
                 str_owner := LTRIM(RTRIM(SUBSTR( str_line, 1, int_n - 1 )));
                 str_name  := LTRIM(RTRIM(SUBSTR( str_line, int_n + 1 )));
              END IF;
           END IF;
       END LOOP;
       IF UPPER(p_type) = 'NAME'
       THEN
          RETURN str_name;
       ELSIF UPPER(p_type) = 'SCHEMA.NAME'
       OR    UPPER(p_type) = 'OWNER.NAME'
       THEN
          RETURN str_owner || '.' || str_name;
       ELSIF UPPER(p_type) = 'TYPE'
       THEN
          RETURN str_type;
       ELSE
          RETURN str_owner;
       END IF;
    END SELF_EXAM;

  • How to get the current date in a workflow

    Hey,
    Can anyone tell me how to get the current date while in a workflow?
    Thanks in advance.

    Here is how we did it, hope it helps
    <defvar name='locCalendar'>
    <new class='java.util.GregorianCalendar'/>
    </defvar>
    <defvar name='dateFormat'>
    <new class='java.text.SimpleDateFormat'>
              <s>MM/dd/yyyy</s>
         </new>
    </defvar>
    <defvar name='formatedDate'>
         <invoke name='getTime'>
    <ref>locCalendar</ref>
    </invoke>
    </defvar>
    <invoke name='format'>
    <ref>dateFormat</ref>
    <ref>formatedDate</ref>
    </invoke>

  • How to get the current month number

    Hi everyone,
    Does anybody know how to get the current month number in Oracle Discoverer Worksheet calculation?
    I try to use EUL_DATE_TRUNC(CURRENT_DATE, 'MM'), but instead I got 01-AUG-00.
    If I change the data display format to MM, it will give me "08" but if I use TO_NUMBER function to convert it to number I get error "invalid number"
    Is there anyway to get the current month value in number? Thanks

    Scott,
    Thank you so much! It works perfectly! :)
    Hope you have a great day ahead!
    Cheers,
    Angeline

  • How to Get the Current Workitem id at runtime

    Hi All,
    I have a scenario, where request pending with a user who has already resigned the organization. The requirement is that we need to provide a report
    of the request and with whom it is pending with along with the workitem id with a forward push button.
    So that if the user identifies that a request is pending with someone he can click the record and press for the forward button and a pop-up to be showed where he can enter the userid to whom he needs to forward it.
    In this scenario can anyone tell me how to get the current workitem id at run time and to save it to a custom table.
    I tried with method before workitem execution, but here i am not getting the current workitem id.
    Can you please suggest a good solution for this.
    Thanks and Regards,
    Balaji

    Karri,
    I think i can explain you with an example.
    Here is my Scenario.
    A user has raised a Gate pass and it went to all approval's and got approved and the material is also sent out from the plant. Lets take the date as 1.1.2013 (A Warehouse person have done the checking and sent out of the plant).
    On 1.3.2013 some of the material has been returned and a material inward request has been raised and now the warehouse person has to do a inward checking and to sent it back for the initiator for the approval, but the warehouse person has resigned the organization on 1.2.2013, now the workitem is pending with the warehouse person who has already resigned.
    My scenario is once the material inward request is created and before the workitem is delivered to the warehouse person i need to get the workitem id and to store the workitem some where.
    So that in future if any warehouse dept head wants to forward the workitem which are lying in the person inbox who has already resigned he can do it via a report using this workitem id.
    So, can anyone help how to get the dialog workitem id before the workitem creation or execution. I tried with "method before workitem execution" but my break point is not triggering at this point.
    Thanks and Regards,
    Balaji

Maybe you are looking for

  • Shared Review Lotus Notes issue

    I'm running Windows XP, Lotus Notes 6.5 and Acrobat Pro Extended 9.2. I want to send a PDF for shared review on a network drive using Lotus Notes to send as attachment.  When I click the "To:" button and enter my Notes password, it comes up by defaul

  • Please list all steps to rename a URL in an email in Mail

    Perhaps I should make this a new question instead of asking it on a reply to another answered question. ============= HOW do you rename a URL in an email? Please list all the steps starting with opening a new email in Mail. I clicked on Add Hyperlink

  • Additional fields in CAT worklist

    Hi, I need to display and populate a custom field for which the screen field is CATS_ADDFI-FIELD1 (additional field1) in CAT worklist.Transaction code is <b>CAT2</b>.The worklist is a table control.How can i achieve this? Regards, Monica.

  • Prepopulate multiple records from a tab delimited text database for distribution, completion, return

    I am using Acrobat 8 Pro and am trying to prepopulate a form about 900 times for distribution, each with its own unique data. I can only get Acrobat to populate form at a time. I can't get LiveCycle to read the data, even as .xml so I have to do this

  • Version control of distributed software

    Like the subject says, I'm working on a way to control versions. I will be writing several small applications that will be used throught the company by 20-30 people. If I do an update or bug fix, I want a way to make sure everyone is using the most r