【问题标题】:how to pass oAuth1.0 consumer key and consumer secret parameters in axios?如何在axios中传递oAuth1.0消费者密钥和消费者秘密参数?
【发布时间】:2020-04-02 00:12:49
【问题描述】:

我想从 woocommerce wordpress 网站获取产品,它需要发送消费者密钥和秘密,但是如何在 react native 中使用 axios 发送它们? 这是邮递员的示例>

【问题讨论】:

    标签: api react-native woocommerce axios


    【解决方案1】:

    你可以使用axios-oauth-1.0a向Axios添加拦截器

    示例代码:

    import axios from 'axios';
    import addOAuthInterceptor from "axios-oauth-1.0a";
    
    // Create a client whose requests will be signed
    const client = axios.create();
    
    // Add interceptor that signs requests
    addOAuthInterceptor(client, {
    // OAuth consumer key and secret
     key: "xxx",
     secret: "yyy",
    // HMAC-SHA1 and HMAC-SHA256 are supported
    algorithm: "HMAC-SHA1",
    });
    
    // Now send requests to the OAuth 1.0a service using that client
    

    【讨论】:

    • 你能发布你的完整代码吗?包括API调用
    猜你喜欢
    • 2017-04-15
    • 1970-01-01
    • 2016-04-14
    • 1970-01-01
    • 2014-08-23
    • 1970-01-01
    • 2013-07-04
    • 2012-07-29
    • 1970-01-01
    相关资源
    最近更新 更多