【问题标题】:authentication using yammer使用 yammer 进行身份验证
【发布时间】:2016-03-11 07:03:20
【问题描述】:

我正在将我的 CRM 应用程序集成到 Yammer,因为我已经在 Yammer 内创建了一个应用程序,并且通过使用 ClientID、客户端密码和重定向 URL,我正在验证 Yammer 用户到应用程序。

问题是,每当用户更改密码或任何其他尝试通过应用程序登录的用户时,它都会询问是否允许许可。如果任何用户使用我的应用程序登录到 yammer,我只是不希望它应该自动允许。请帮助我解决这个问题,我也在发布我的代码

referalUrl = oauthUrl + clientId;
            oauthUrl =oauthUrl+ clientId + "&redirect_uri=" + redirUrl;      //For authentication to Yammer
            //referalUrl = oauthUrl + clientId;
            accessTokenUrl = accessTokenUrl + "client_id=" + clientId + "&client_secret=" + clientSecret + "&code=";
            string qsCode = string.Empty;
            string accessToken = "";
            string postResults = string.Empty;
            string response = string.Empty;
            string firstName = string.Empty;
            string lastName = string.Empty;
            //string currentUser = string.Empty;
            object yammerUserId = this.PrimaryDataRow[YammerUserTable.Field.YammerUserId];
            object currentUserId = this.SystemClient.UserProfile.EmployeeId;


        if (string.IsNullOrEmpty(accessToken))
        {
            while (string.IsNullOrEmpty(qsCode))
            {
                response = YammerAPIRequest.MakeGetRequest(oauthUrl, null, true);

                //look for authenticity token
                string authToken = YammerAPIRequest.GetAuthenticityToken(response);

                if (!string.IsNullOrEmpty(authToken))
                {
                    string f = System.Web.HttpUtility.UrlEncode(authToken);

                    userName = System.Web.HttpUtility.UrlEncode(userName);
                    //password = System.Web.HttpUtility.UrlEncode(password);
                    string postBody = "utf8=%E2%9C%93&authenticity_token=" + System.Web.HttpUtility.UrlEncode(authToken) + "&network_permalink=aptean.com&login=" +
                        userName + "&password=" + password + "&remember_me=on";

                    postResults = YammerAPIRequest.MakeLoginPostRequest(postBody, loginUrl, f, null, referalUrl);
                }
                qsCode = postResults;
                if (qsCode.IndexOf("code") == -1 && qsCode.IndexOf("redirect_uri")==-1)
                {
                    PivotalMessageBox.Show("Please enter Correct Username or Password");
                    return false;
                }
                else
                {
                    PivotalMessageBox.Show("You have Logged in to Yammer");
                    string postreq = "utf8=%E2%9C%93&authenticity_token=" + System.Web.HttpUtility.UrlEncode(authToken) + "&allow=Allow";
                    string allowurl="https://www.yammer.com/aptean.com/oauth2/decision?client_id=BAUC8GdiEZ5ximkabWM9Q&redirect_uri=https%3A%2F%2Fwww.yammer.com%2Faptean.com%2F&response_type=code";
                    string allow = YammerAPIRequest.AllowtoApp(postreq, allowurl, authToken, null, null);
                    if (allow != "")
                    {
                        qsCode = allow;
                    }

【问题讨论】:

    标签: rest yammer office365-restapi


    【解决方案1】:

    如果任何用户使用我的应用程序登录到 yammer,我只是不想要这个 它应该自动允许

    这是设计使然,不能从您的代码中更改/绕过。必须为用户提供允许或拒绝使用 yammer 第三方应用程序的选项。

    如果适合您的用例,您可以考虑使用模拟端点 - https://developer.yammer.com/docs/impersonation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多