{"action":"created","issue":{"url":"https://api.github.com/repos/matthew-andrews/isomorphic-fetch/issues/112","repository_url":"https://api.github.com/repos/matthew-andrews/isomorphic-fetch","labels_url":"https://api.github.com/repos/matthew-andrews/isomorphic-fetch/issues/112/labels{/name}","comments_url":"https://api.github.com/repos/matthew-andrews/isomorphic-fetch/issues/112/comments","events_url":"https://api.github.com/repos/matthew-andrews/isomorphic-fetch/issues/112/events","html_url":"https://github.com/matthew-andrews/isomorphic-fetch/issues/112","id":185662981,"number":112,"title":"How to format headers for api call ","user":{"login":"StephenGrable1","id":19244434,"avatar_url":"https://avatars.githubusercontent.com/u/19244434?v=3","gravatar_id":"","url":"https://api.github.com/users/StephenGrable1","html_url":"https://github.com/StephenGrable1","followers_url":"https://api.github.com/users/StephenGrable1/followers","following_url":"https://api.github.com/users/StephenGrable1/following{/other_user}","gists_url":"https://api.github.com/users/StephenGrable1/gists{/gist_id}","starred_url":"https://api.github.com/users/StephenGrable1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StephenGrable1/subscriptions","organizations_url":"https://api.github.com/users/StephenGrable1/orgs","repos_url":"https://api.github.com/users/StephenGrable1/repos","events_url":"https://api.github.com/users/StephenGrable1/events{/privacy}","received_events_url":"https://api.github.com/users/StephenGrable1/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-27T13:05:53Z","updated_at":"2016-11-01T22:48:43Z","closed_at":"2016-10-27T13:37:31Z","body":"I am currently trying to get a oath token (Bearer key for twitter's application-only authentication) from twitter's api. You can check out the docs here -> https://dev.twitter.com/oauth/application-only\n\nI'm using react/redux, express/node and isomorphic-fetch to call the api but I am getting a response of 404. Twitters doc's say that if the page is responding with a 404 then the request is probably not formatted correctly.\n\nAfter that I went into the console and checked the network request. I see all of the correctly formatted requests but my \"Authorization\" header is no where to be found. I'm wondering if I am formatting the api call correctly. I couldn't find any good resources on formatting headers for api calls for isomorphic-fetch. Here is my actions.jsx file where I am making the call \n\n```\n//actions.jsx file\n\n   import fetch from 'isomorphic-fetch';\n\n//this is my action \n   export var fetchTwtBearerToken = () => {\n     return dispatch => {\n\n    //Here I am just formatting my keys \n    var urlEncodeConsumerKey = encodeURI(process.env.TWT_CONSUMER_KEY);\n    var urlEncodeConsumerSec = encodeURI(process.env.TWT_CONSUMER_SECRET);\n    var bearerToken = urlEncodeConsumerKey + ':' + urlEncodeConsumerSec;\n    var base64BearerToken = btoa(bearerToken);\n    console.log(base64BearerToken);\n\n      // Here is where I start the call \n\n    return fetch('https://api.twitter.com/oauth2/token', {\n      method:'post',\n      headers: {\n        'Authorization': 'Basic ' + base64BearerToken,\n        'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'\n      },\n      body: 'grant_type=client_credentials',\n      mode: 'no-cors'\n    })\n      .then(response => response.json().then(json => ({\n        status: response.status,\n        response: response,\n        json\n      })\n    ))\n      .then(({status, json}) => {\n        if (status >= 400) {\n          console.log(status, response, 'bad fetching');\n        } else {\n          console.log('good fetching');\n        }\n      })\n\n  };\n};\n```\n\nI'm desperately trying to find out if I am formatting the headers correctly or where I am going wrong here. Any help in the right direction is very much appreciated. \n"},"comment":{"url":"https://api.github.com/repos/matthew-andrews/isomorphic-fetch/issues/comments/257722350","html_url":"https://github.com/matthew-andrews/isomorphic-fetch/issues/112#issuecomment-257722350","issue_url":"https://api.github.com/repos/matthew-andrews/isomorphic-fetch/issues/112","id":257722350,"user":{"login":"martinhorsky","id":3922865,"avatar_url":"https://avatars.githubusercontent.com/u/3922865?v=3","gravatar_id":"","url":"https://api.github.com/users/martinhorsky","html_url":"https://github.com/martinhorsky","followers_url":"https://api.github.com/users/martinhorsky/followers","following_url":"https://api.github.com/users/martinhorsky/following{/other_user}","gists_url":"https://api.github.com/users/martinhorsky/gists{/gist_id}","starred_url":"https://api.github.com/users/martinhorsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martinhorsky/subscriptions","organizations_url":"https://api.github.com/users/martinhorsky/orgs","repos_url":"https://api.github.com/users/martinhorsky/repos","events_url":"https://api.github.com/users/martinhorsky/events{/privacy}","received_events_url":"https://api.github.com/users/martinhorsky/received_events","type":"User","site_admin":false},"created_at":"2016-11-01T22:48:43Z","updated_at":"2016-11-01T22:48:43Z","body":"@StephenGrable1 I have the same issue. Did you solve it?"}}
{"actor":{"display_login":"martinhorsky"}}