Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6354451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:34:40+00:00 2026-05-24T22:34:40+00:00

i have been searching on the net from last 2 days for MVC Implementation

  • 0

i have been searching on the net from last 2 days for MVC Implementation of OAuthConsumer Sample in DotNetOpenAuth, but still i did not found any solution.
i had also tried to convert OAuthConsumer implementation from WebForms to MVC, but still unable to implement it correctly.
can anybody please help by referring some place to find a converter sample.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:34:41+00:00Added an answer on May 24, 2026 at 10:34 pm

    After 2 days of struggle I resolved the issue as follows, but I think it needs some more improvement.

    private string AccessToken
    {
        get { return (string)Session["GoogleAccessToken"]; }
        set { Session["GoogleAccessToken"] = value; }
    }
    
    private InMemoryTokenManager TokenManager
    {
        get
        {
            var tokenManager = (InMemoryTokenManager)HttpContext.Application["GoogleTokenManager"];
            if (tokenManager == null)
            {
                string consumerKey = ConfigurationManager.AppSettings["GoogleOAuthConsumerKey"];
                string consumerSecret = ConfigurationManager.AppSettings["GoogleOAuthConsumerValue"];
                if (!string.IsNullOrEmpty(consumerKey))
                {
                    tokenManager = new InMemoryTokenManager(consumerKey, consumerSecret);
                    HttpContext.Application["GoogleTokenManager"] = tokenManager;
                }
            }
    
            return tokenManager;
        }
    }
    
    
    public ActionResult GoogleSync()
    {
        var google = new WebConsumer(GoogleConsumer.ServiceDescription, this.TokenManager);
    
        // Is Google calling back with authorization?
        var accessTokenResponse = google.ProcessUserAuthorization();
        if (accessTokenResponse != null)
        {
            this.AccessToken = accessTokenResponse.AccessToken;
            XDocument contactsDocument = GoogleConsumer.GetContacts(google, this.AccessToken, 5, 1);
            var contactList = new List<GMailContact>();
            foreach (var entry in contactsDocument.Root.Elements(XName.Get("entry", "http://www.w3.org/2005/Atom")))
            {
                GMailContact newContact = new GMailContact { Name = string.Empty, Email = string.Empty };
                var titleElement = entry.Element(XName.Get("title", "http://www.w3.org/2005/Atom"));
                if (titleElement != null)
                    newContact.Name = titleElement.Value;
                var emailElement = entry.Element(XName.Get("email", "http://schemas.google.com/g/2005"));
                if (emailElement != null && emailElement.Attribute("address") != null)
                {
                    newContact.Email = emailElement.Attribute("address").Value;
                }
    
                contactList.Add(newContact);
            }
    
            ////var contacts = from entry in contactsDocument.Root.Elements(XName.Get("entry", "http://www.w3.org/2005/Atom"))
            ////               select new { Name = entry.Element(XName.Get("title", "http://www.w3.org/2005/Atom")).Value,
            ////                            Email = (XName.Get("email", "http://schemas.google.com/g/2005") == null ? "" : entry.Element(XName.Get("email", "http://schemas.google.com/g/2005")).Attribute("address").Value) };
    
            return View(contactList);
        }
        else if (this.AccessToken == null)
        {
            // If we don't yet have access, immediately request it.
            GoogleConsumer.RequestAuthorization(google, GoogleConsumer.Applications.Contacts);
    
            return this.Content("");
        }
        else
        {
    
            return this.Content("synchronization failed.");
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been searching for an hour on how to use FFmpeg from .NET
I have been searching everywhere but I could not find an answer. I need
I have been searching around using Google but I can't find an answer to
How to continue from where I have been searching to find the index? I
Have been looking at the MVC storefront and see that IQueryable is returned from
I have done some searching around but have not been able to figure out
From searching I can see this has been asked time and time again, but
I have been searching high/low on the GooglePlex and here for a sample MVC3
I have been searching for a solution for the past two days now. I
I have been searching for an answer to this question for days and it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.