Пример #1
0
        public string GetUrlForAuthorizationCode(GmailAuth gmailAuth)
        {
            var url = new StringBuilder(gmailAuth.auth_uri);

            url.Append("?client_id=").Append(gmailAuth.client_id)
            .Append("&response_type=").Append(gmailAuth.response_type)
            .Append("&redirect_uri=").Append(gmailAuth.redirect_uri)
            .Append("&scope=").Append(gmailAuth.scope);

            // var urlLink = $"{gmailAuth.auth_uri}?client_id={gmailAuth.client_id}&response_type={gmailAuth.response_type}&redirect_uri={gmailAuth.redirect_uri}&scope={gmailAuth.scope}";
            return(url.ToString());
        }
Пример #2
0
        public FormUrlEncodedContent GetUrlEncodedContent(GmailAuth gmailAuth, string code)
        {
            var objJson = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair <string, string>("grant_type", "authorization_code")
                , new KeyValuePair <string, string>("code", code)
                , new KeyValuePair <string, string>("redirect_uri", gmailAuth.redirect_uri)
                , new KeyValuePair <string, string>("client_id", gmailAuth.client_id)                        //consider sending via basic authentication header
                , new KeyValuePair <string, string>("client_secret", gmailAuth.client_secret)
            });

            return(objJson);
        }