Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string access_token = Request.Params["access_token"];
            string code         = Request.Params["code"];

            if (!String.IsNullOrEmpty(code))
            {
                RS.setCode(code);
                //Response.Redirect(RS.get_token_url);

                HttpWebRequest             request           = (HttpWebRequest)WebRequest.Create(RS.get_token_url);
                HttpWebResponse            response          = (HttpWebResponse)request.GetResponse();
                DataContractJsonSerializer serializer        = new DataContractJsonSerializer(typeof(JsonDataStrcuture));
                JsonDataStrcuture          JsonDataStrcuture = new JsonDataStrcuture();
                JsonDataStrcuture = serializer.ReadObject(response.GetResponseStream()) as JsonDataStrcuture;

                FBResourceRequest req = new FBResourceRequest();
                req.access_token       = new AccessToken();
                req.access_token.token = JsonDataStrcuture.AccessToken;
                req.UserID             = user_id;
                req.scope = new GenericAuthNameSpace.Permissions();
                req.scope.permissionSet = new HashSet <GenericAuthNameSpace.Permission>();
                req.scope.permissionSet.Add(new ResourceServerImpl.FBEmailPermission());

                FBResourceResponse resp = RS.RequestResource(req);
                if (resp == null)
                {
                    email.InnerHtml = "verification failed";
                }
                else
                {
                    Resource r = resp.resources.resourceSet.First();
                    email.InnerHtml = "John's email is " + r.value;
                }
            }
            else if (!String.IsNullOrEmpty(access_token))
            {
                notLoggedIn.Visible = false;
                LoggedIn.Visible    = true;
            }
            else
            {
                notLoggedIn.Visible = true;
                LoggedIn.Visible    = false;
            }
        }
Пример #2
0
        public FBResourceResponse RequestResource(FBResourceRequest req)
        {
            if (HasPermissionForResource(req))
            {
                Resources recources = new Resources();
                recources.resourceSet = new HashSet<Resource>();

                foreach (Permission perm in req.scope.permissionSet)
                {
                    recources.resourceSet.Add(ResourceRecs.getEntry(req.UserID, perm));
                }

                FBResourceResponse rr = new FBResourceResponse();
                rr.client_id = req.client_id;
                rr.access_token = req.access_token;
                rr.resources = recources;

                return rr;
            }
            return null;
        }
Пример #3
0
        public FBResourceResponse RequestResource(FBResourceRequest req)
        {
            if (HasPermissionForResource(req))
            {
                Resources recources = new Resources();
                recources.resourceSet = new HashSet <Resource>();

                foreach (Permission perm in req.scope.permissionSet)
                {
                    recources.resourceSet.Add(ResourceRecs.getEntry(req.UserID, perm));
                }

                FBResourceResponse rr = new FBResourceResponse();
                rr.client_id    = req.client_id;
                rr.access_token = req.access_token;
                rr.resources    = recources;

                return(rr);
            }
            return(null);
        }