https://discord.cloudflare.com logo
Join Discord
Powered by
# workers-discussions
  • d

    dave

    02/23/2023, 8:46 PM
    oh wait I put my service binding in the wrong spot
  • d

    dave

    02/23/2023, 8:47 PM
    ayyy that worked
  • d

    dave

    02/23/2023, 8:51 PM
    this is what I tried, didn't seem to work.
    Copy code
    const rebuilt_url = new URL(`https://${incoming_domain}/unsubscribe/${subject_raw_header}`);
    console.debug(`rebuilt_url: ${rebuilt_url.toString()}`);
    
    const unsub_fetch_request = new Request(rebuilt_url, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
        body: "List-Unsubscribe=One-Click"
    });
    const unsub_fetch_promise = this.fetch(unsub_fetch_request);
    const unsub_fetch_promise_result = await unsub_fetch_promise;
    console.debug(`unsub_fetch_promise_result: ${JSON.stringify(unsub_fetch_promise_result, null, 2)}`);
    console.debug(`unsub_fetch_promise_result: ${unsub_fetch_promise_result.status}`);
    
    console.debug(`unsub_fetch_promise_text: ${await (unsub_fetch_promise_result).text()}`);
  • k

    kian

    02/23/2023, 8:52 PM
    assuming
    this.fetch
    is called from the
    email
    handler in
    export default
    ?
  • k

    kian

    02/23/2023, 8:52 PM
    i assume if it's called in another function then it might not work
  • d

    dave

    02/23/2023, 8:53 PM
    Copy code
    typescript
    export default {
        fetch: app.fetch,
        async email(email_message: EmailMessage, env: Env, ctx: ExecutionContext) {
            // that stuff here
        }
    }
  • k

    kian

    02/23/2023, 8:53 PM
  • d

    dave

    02/23/2023, 8:55 PM
    all good, the self referencing service binding thing is fine, since this is just a temp workaround anyway
  • j

    johtso

    02/23/2023, 11:09 PM
    does anyone know of a CF worker compatible oauth1 library?
  • j

    johtso

    02/23/2023, 11:10 PM
    I remember looking about a year ago and didn't have any luck
  • j

    johtso

    02/23/2023, 11:11 PM
    this requires a synchronous hash function https://www.npmjs.com/package/oauth-1.0a
  • j

    johtso

    02/23/2023, 11:12 PM
    and webcrypto only gives you an async interface
  • z

    zszszsz

    02/23/2023, 11:56 PM
    why must it be sync
  • j

    johtso

    02/24/2023, 12:30 AM
    @zszszsz it's just the way the library was written, it takes a
    hash_function
    that can't be async
  • z

    zszszsz

    02/24/2023, 12:31 AM
    I see
  • z

    zszszsz

    02/24/2023, 12:32 AM
    It has no activity after yr 2019. Probably you want to find another library
  • z

    zszszsz

    02/24/2023, 12:32 AM
    why must it be oa1 but not oa2
  • j

    johtso

    02/24/2023, 12:33 AM
    @zszszsz I want to interact with the Flickr API which is ancient oauth1
  • j

    johtso

    02/24/2023, 12:35 AM
    I ended up writing it in Python which I managed to get working easily with the
    authlib
    library..
  • j

    johtso

    02/24/2023, 12:35 AM
    but I'd love to migrate it over to workers
  • z

    zszszsz

    02/24/2023, 12:37 AM
    I would bet on there might be some Oauth2 libraries providing oauth1 features
  • z

    zszszsz

    02/24/2023, 12:38 AM
    Or you would have to do it yourself
  • z

    zszszsz

    02/24/2023, 12:38 AM
    since it is ancient
  • j

    johtso

    02/24/2023, 12:39 AM
    I couldn't find it.. and when I tried to hack something together I couldn't get the signature to be valid
  • z

    zszszsz

    02/24/2023, 12:47 AM
    @johtso try this https://github.com/ddo/oauth-1.0a/compare/master...yw662:oauth-1.0a:patch-1
  • j

    johtso

    02/24/2023, 12:49 AM
    Yeah I tried that but couldn't get my signatures to work, hence trying to find something that worked off the shelf with webcrypto
  • z

    zszszsz

    02/24/2023, 12:51 AM
    hmmm then there must be sth. wrong with that lib
  • z

    zszszsz

    02/24/2023, 12:52 AM
    So you tried to manually add all these async and await and it won't work ?
  • j

    johtso

    02/24/2023, 12:54 AM
    @zszszsz https://stackoverflow.com/questions/71937505/interacting-with-oauth1-api-in-cloudflare-worker-flickr
  • z

    zszszsz

    02/24/2023, 12:54 AM
    `Asked 10 months ago Modified 10 months ago Viewed 93 times
1...230223032304...2509Latest