public async Task <JObject> GetUserProfileAsync() { Credencial credencial = await CredencialService.FromSessionAsync(Request.Cookies, Response.Cookies); if (credencial == null) { return(null); } // the API SDK UserProfileApi userApi = new UserProfileApi(); userApi.Configuration.AccessToken = credencial.TokenInternal; // get the user profile dynamic userProfile = await userApi.GetUserProfileAsync(); // prepare a response with name & picture dynamic response = new JObject(); response.name = string.Format("{0} {1}", userProfile.firstName, userProfile.lastName); response.picture = userProfile.profileImages.sizeX40; response.token = credencial.TokenInternal; return(response); }
public async Task <AccessToken> GetPublicTokenAsync() { Credencial credencial = await CredencialService.FromSessionAsync(Request.Cookies, Response.Cookies); if (credencial == null) { base.Response.StatusCode = (int)HttpStatusCode.Unauthorized; return(new AccessToken()); } // return the public (viewables:read) access token return(new AccessToken() { access_token = credencial.TokenPublic, expires_in = (int)credencial.ExpiresAt.Subtract(DateTime.Now).TotalSeconds }); //Credentials credentials = await Credentials.FromSessionAsync(Request.Cookies, Response.Cookies); //if (credentials == null) //{ // base.Response.StatusCode = (int)HttpStatusCode.Unauthorized; // return new AccessToken(); //} //// return the public (viewables:read) access token //return new AccessToken() //{ // access_token = credentials.TokenPublic, // expires_in = (int)credentials.ExpiresAt.Subtract(DateTime.Now).TotalSeconds //}; }