@@ -3,7 +3,7 @@ import WordpressPlugin from './main';
33import { WpProfile } from './wp-profile' ;
44import { EventType , WP_OAUTH2_REDIRECT_URI } from './consts' ;
55import { WordPressClientReturnCode } from './wp-client' ;
6- import { generateCodeVerifier , OAuth2Client } from './oauth2-client' ;
6+ import { generateCodeVerifier , OAuth2Client , WordPressOAuth2Token } from './oauth2-client' ;
77import { AppState } from './app-state' ;
88import { isValidUrl , showError } from './utils' ;
99import { ApiType } from './plugin-settings' ;
@@ -62,11 +62,13 @@ class WpProfileModal extends AbstractModal {
6262 super ( plugin ) ;
6363
6464 this . profileData = Object . assign ( { } , profile ) ;
65- this . tokenGotRef = AppState . events . on ( EventType . OAUTH2_TOKEN_GOT , async token => {
66- this . profileData . wpComOAuth2Token = token ;
65+ this . tokenGotRef = AppState . events . on ( EventType . OAUTH2_TOKEN_GOT , async token => {
66+ const tokenData = token as WordPressOAuth2Token ;
67+ console . log ( 'WpProfileModal.onTokenGot' , tokenData ) ;
68+ this . profileData . wpComOAuth2Token = tokenData ;
6769 if ( atIndex >= 0 ) {
6870 // if token is undefined, just remove it
69- this . plugin . settings . profiles [ atIndex ] . wpComOAuth2Token = token ;
71+ this . plugin . settings . profiles [ atIndex ] . wpComOAuth2Token = tokenData ;
7072 await this . plugin . saveSettings ( ) ;
7173 }
7274 } ) ;
0 commit comments