public void GetAccessToken(string code) { JsonSerializer serializer = new JsonSerializer(); ErrorLogger errorLogger = new ErrorLogger(); string client_id = _configuration.GetSection("Transsped").GetSection("ClientID").Value; string client_secret = _configuration.GetSection("Transsped").GetSection("ClientSecret").Value; string redirect_uri = _configuration.GetSection("Transsped").GetSection("RedirectURL").Value; string token_url = _configuration.GetSection("Transsped").GetSection("TokenURL").Value; string baseURL = _configuration.GetSection("Transsped").GetSection("BaseURL").Value; OAuth2Client oAuth2Client = new OAuth2Client(serializer, errorLogger, baseURL); InputOAuth2Token inputOAuth2Token = new InputOAuth2Token() { client_id = client_id, client_secret = client_secret, code = code, grant_type = "authorization_code", redirect_uri = redirect_uri }; var responseToken = oAuth2Client.GetOauth2Token("token", serializer.Serialize(inputOAuth2Token)); var serializedResponseToken = serializer.Serialize(responseToken); if (!serializedResponseToken.Contains("error")) { OutputOauth2Token oauth2Token = serializer.Deserialize <OutputOauth2Token>(serializedResponseToken); _accessToken.SetAccessToken(oauth2Token.access_token, oauth2Token.token_type, oauth2Token.expires_in); } }
public void SetAccessToken(string access_token, string token_type, int expires_in) { AccessToken = new OutputOauth2Token(); AccessToken.access_token = access_token; AccessToken.token_type = token_type; AccessToken.expires_in = expires_in; }