// Fill device request handle for refreshing access token internal IntPtr GetRequestHandle(RefreshTokenRequest request) { IntPtr requestHandle; int ret = Interop.Request.Create(out requestHandle); if (ret != (int)OAuth2Error.None) { Log.Error(ErrorFactory.LogTag, "Interop failed"); throw ErrorFactory.GetException(ret); } ret = Interop.Request.SetRefreshTokenUrl(requestHandle, request.TokenEndpoint.ToString()); if (ret != (int)OAuth2Error.None) { Log.Error(ErrorFactory.LogTag, "Interop failed"); throw ErrorFactory.GetException(ret); } ret = Interop.Request.SetGrantType(requestHandle, Interop.GrantType.Refresh); if (ret != (int)OAuth2Error.None) { Log.Error(ErrorFactory.LogTag, "Interop failed"); throw ErrorFactory.GetException(ret); } ret = Interop.Request.SetRefreshToken(requestHandle, request.RefreshToken); if (ret != (int)OAuth2Error.None) { Log.Error(ErrorFactory.LogTag, "Interop failed"); throw ErrorFactory.GetException(ret); } if (request.ClientSecrets.Id != null) { ret = Interop.Request.SetClientId(requestHandle, request.ClientSecrets.Id); if (ret != (int)OAuth2Error.None) { Log.Error(ErrorFactory.LogTag, "Interop failed"); throw ErrorFactory.GetException(ret); } } if (request.ClientSecrets.Secret != null) { ret = Interop.Request.SetClientSecret(requestHandle, request.ClientSecrets.Secret); if (ret != (int)OAuth2Error.None) { Log.Error(ErrorFactory.LogTag, "Interop failed"); throw ErrorFactory.GetException(ret); } } if (request.Scopes != null) { string scope = string.Join(" ", request.Scopes); ret = Interop.Request.SetScope(requestHandle, scope); if (ret != (int)OAuth2Error.None) { Log.Error(ErrorFactory.LogTag, "Interop failed"); throw ErrorFactory.GetException(ret); } } ret = Interop.Request.SetClientAuthenticationType(requestHandle, (int)request.AuthenticationScheme); if (ret != (int)OAuth2Error.None) { Log.Error(ErrorFactory.LogTag, "Interop failed"); throw ErrorFactory.GetException(ret); } return(requestHandle); }
/// <summary> /// Refreshing access token is not supported in this flow. /// </summary> /// <since_tizen> 3 </since_tizen> /// <exception cref="InvalidOperationException">Thrown when the operation is not supported</exception> public override Task <TokenResponse> RefreshAccessTokenAsync(RefreshTokenRequest request) { Log.Error(ErrorFactory.LogTag, "Refesh token is not supported in Implicit Grant flow"); throw new InvalidOperationException(); }
/// <summary> /// Retrieves access token using a refresh token. /// </summary> /// <since_tizen> 3 </since_tizen> /// <param name="request">Request containing refresh token</param> /// <returns>The response containing access token.</returns> /// <privilege>http://tizen.org/privilege/internet</privilege> /// <exception cref="ArgumentException">Thrown when method failed due to invalid argumets</exception> /// <exception cref="OAuth2Exception">Thrown when method fails due to server error</exception> public virtual async Task <TokenResponse> RefreshAccessTokenAsync(RefreshTokenRequest request) { IntPtr requestHandle = GetRequestHandle(request); return(await Task.Run(() => GetRefreshToken(requestHandle))); }