Skip to content
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

Etsy API doesn't return parameter.codeVerifier_ ? #448

Open
MOhhh-ok opened this issue Jun 1, 2023 · 2 comments
Open

Etsy API doesn't return parameter.codeVerifier_ ? #448

MOhhh-ok opened this issue Jun 1, 2023 · 2 comments
Assignees

Comments

@MOhhh-ok
Copy link

MOhhh-ok commented Jun 1, 2023

Hi.

Etsy seems to be not return codeVerifire_ parameter.

The error is "Error retrieving token: invalid_request, code_verifier is required"

So, I tried below code, then it works.

    function EtsyAuthCallback(request: { [key: string]: any }) {
        const oauth = new EtsyOAuth(); // Wrapper class
        const service = oauth.getService();
 
        // ignore the error: Error retrieving token: invalid_request, code_verifier is required
        request.parameter.codeVerifier_ = PropertiesService.getUserProperties().getProperty('code_verifier');

        const isAuthorized = service.handleCallback(request);
        if (isAuthorized) {
            return HtmlService.createHtmlOutput('Success! You can close this tab.');
        } else {
            return HtmlService.createHtmlOutput('Denied. You can close this tab');
        }
    }

Is this an issue, or my mistake?
Thanks.

@erickoledadevrel
Copy link
Contributor

Are you writing the code verifier as shown in this other sample?

function pkceChallengeVerifier() {
var userProps = PropertiesService.getUserProperties();
if (!userProps.getProperty('code_verifier')) {
var verifier = '';
var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~';
for (var i = 0; i < 128; i++) {
verifier += possible.charAt(Math.floor(Math.random() * possible.length));
}
var sha256Hash = Utilities.computeDigest(Utilities.DigestAlgorithm.SHA_256, verifier);
var challenge = Utilities.base64Encode(sha256Hash)
.replace(/\+/g, '-')
.replace(/\//g, '_')
.replace(/=+$/, '');
userProps.setProperty('code_verifier', verifier);
userProps.setProperty('code_challenge', challenge);
}
}

@MOhhh-ok
Copy link
Author

Yeah, I am writing that code.
So I can find the correct code_verifier from the user properties.
The problem is that the code_verifier is not in the request object parameter in the callback function.

@MOhhh-ok MOhhh-ok reopened this Jun 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants