-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add token exchange update procedure. #845
Add token exchange update procedure. #845
Conversation
Hey, @budzanowski ! Here: pinterest-for-woocommerce/src/API/Base.php Lines 288 to 290 in 9aed51b
As a result of We can redo public static function get_token() {
if ( is_null( self::$token ) ) {
self::$token = Pinterest_For_Woocommerce()::get_data( 'token', true );
}
return self::$token;
} |
Sorry for the hassle. I was too lazy to constantly change branches so I was injecting the v3 token manually for testing. This latest change ae22258 should fix the issue. |
src/API/TokenExchangeV3ToV5.php
Outdated
* @return string $token The V3 token. | ||
*/ | ||
public static function get_token() { | ||
return Pinterest_For_Woocommerce()::get_data( 'token', true ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, @budzanowski
The last change.
We need to Pinterest/Crypto::decrypt()
our [access_token]
.
return Pinterest_For_Woocommerce()::get_data( 'token', true ); | |
$token = Pinterest_For_Woocommerce()::get_data( 'token', true ); | |
try { | |
$token['access_token'] = empty( $token['access_token'] ) ? '' : Pinterest\Crypto::decrypt( $token['access_token'] ); | |
} catch ( \Exception $th ) { | |
/* Translators: The error description */ | |
Pinterest\Logger::log( sprintf( esc_html__( 'Could not decrypt the Pinterest API access token. Try reconnecting to Pinterest. [%s]', 'pinterest-for-woocommerce' ), $th->getMessage() ), 'error' ); | |
} | |
return $token; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I had my access token in the DB in a plane text.
Co-authored-by: message-dimke <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works as expected. Token exchange endpoint succeeds and we get v5 token from it. Also it gets saved into a database.
Thank you, @budzanowski !
Changes proposed in this Pull Request:
When the plugin gets updated the token exchange procedure should be triggered.
Closes #844 .
Relies on #840.
Detailed test instructions:
PINTEREST_FOR_WOOCOMMERCE_VERSION
to1.4.0