Example #1
0
        public void TestCreateFromRefreshTokenDynamic()
        {
            Dictionary<string, string> configurationMap = new Dictionary<string, string>();
            configurationMap.Add("clientId", "");
            configurationMap.Add("clientSecret", "");
            configurationMap.Add("mode", "live");
            APIContext apiContext = new APIContext();
            apiContext.Config = configurationMap;

            CreateFromRefreshTokenParameters param = new CreateFromRefreshTokenParameters();
            info = info.CreateFromRefreshToken(apiContext, param);
            Assert.AreEqual(info.access_token != null, true);
        }
Example #2
0
        /// <summary>
        /// Creates an Access Token from an Refresh Token
        /// <param name="apiContext">APIContext to be used for the call</param>
        /// <param name="createFromRefreshTokenParameters">Query parameters used for API call</param>
        /// </summary>
        public Tokeninfo CreateFromRefreshToken(APIContext apiContext, CreateFromRefreshTokenParameters createFromRefreshTokenParameters)
        {
            string pattern = "v1/identity/openidconnect/tokenservice?grant_type={0}&refresh_token={1}&scope={2}&client_id={3}&client_secret={4}";

            createFromRefreshTokenParameters.SetRefreshToken(HttpUtility.UrlEncode(refresh_token));
            object[] parameters   = new object[] { createFromRefreshTokenParameters };
            string   resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
            string   payLoad      = resourcePath.Substring(resourcePath.IndexOf('?') + 1);

            resourcePath = resourcePath.Substring(0, resourcePath.IndexOf("?"));
            Dictionary <string, string> headersMap = new Dictionary <string, string>();

            headersMap.Add(BaseConstants.ContentTypeHeader, "application/x-www-form-urlencoded");
            if (apiContext == null)
            {
                apiContext = new APIContext();
            }
            apiContext.HTTPHeaders   = headersMap;
            apiContext.MaskRequestId = true;
            return(PayPalResource.ConfigureAndExecute <Tokeninfo>(apiContext, HttpMethod.POST, resourcePath, payLoad));
        }
Example #3
0
 /// <summary>
 /// Creates an Access Token from an Refresh Token
 /// <param name="apiContext">APIContext to be used for the call</param>
 /// <param name="createFromRefreshTokenParameters">Query parameters used for API call</param>
 /// </summary>
 public Tokeninfo CreateFromRefreshToken(APIContext apiContext, CreateFromRefreshTokenParameters createFromRefreshTokenParameters)
 {
     string pattern = "v1/identity/openidconnect/tokenservice?grant_type={0}&refresh_token={1}&scope={2}&client_id={3}&client_secret={4}";
     createFromRefreshTokenParameters.SetRefreshToken(HttpUtility.UrlEncode(refresh_token));
     object[] parameters = new object[] { createFromRefreshTokenParameters };
     string resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
     string payLoad = resourcePath.Substring(resourcePath.IndexOf('?') + 1);
     resourcePath = resourcePath.Substring(0, resourcePath.IndexOf("?"));
     Dictionary<string, string> headersMap = new Dictionary<string, string>();
     headersMap.Add(BaseConstants.ContentTypeHeader, "application/x-www-form-urlencoded");
     if (apiContext == null)
     {
         apiContext = new APIContext();
     }
     apiContext.HTTPHeaders = headersMap;
     apiContext.MaskRequestId = true;
     return PayPalResource.ConfigureAndExecute<Tokeninfo>(apiContext, HttpMethod.POST, resourcePath, payLoad);
 }
Example #4
0
 /// <summary>
 /// Creates an Access Token from an Refresh Token.
 /// <param name="createFromRefreshTokenParameters">Query parameters used for API call</param>
 /// </summary>
 public Tokeninfo CreateFromRefreshToken(CreateFromRefreshTokenParameters createFromRefreshTokenParameters)
 {
     return CreateFromRefreshToken(null, createFromRefreshTokenParameters);
 }
Example #5
0
 /// <summary>
 /// Creates an Access Token from an Refresh Token.
 /// <param name="createFromRefreshTokenParameters">Query parameters used for API call</param>
 /// </summary>
 public Tokeninfo CreateFromRefreshToken(CreateFromRefreshTokenParameters createFromRefreshTokenParameters)
 {
     return(CreateFromRefreshToken(null, createFromRefreshTokenParameters));
 }