phallstrom / AlfredGist

An workflow for Alfred to create Gists from your clipboard contents or selected file(s).
159 stars 10 forks source link

Can't setup AfredGist #13

Closed mhenrixon closed 10 years ago

mhenrixon commented 10 years ago

All I get is ERROR: An API error occured. even though I know for a fact I used the right credentials.

phallstrom commented 10 years ago

Hrm. New installation? Need you to trouble shoot for me... open a terminal and type:

cd "`grep -l -- ">pjkh.gist<" "$HOME/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows"/*/info.plist | sed 's/\/info.plist//'`"

Then type:

sh setup.sh

This will walk you through the same setup as normal. Send me all of the output.

Then type the following and send me all of the output.

cat "$HOME/Library/Application Support/Alfred 2/Workflow Data/pjkh.gist/config"
mhenrixon commented 10 years ago
➜  user.workflow.703D3740-B1DA-4A10-A3F1-BF2BE8DF3838  sh setup.sh

Gist for AlfredApp Setup
=========================================================================

This script will make a request to the GitHub API and get
authorization to create Gists on your behalf.  Note that this also
grants permission edit and delete Gists, but we don't do that.
Just wanted you to know.

You will need to provider your GitHub username and password. These are
passed to curl and used to authenticate your request.  This request is
made over SSL.

If an error occurs the response from GitHub will be returned.

If successful, a token will be set.  You should also see an entry for
"Gist for AlfredApp" at the following URL:

  https://github.com/settings/applications

If you want to use this workflow with a private Github installation
you must enter the hostname of your Github server when asked. By default
this workflow will use api.github.com.

Please enter your GitHub server [api.github.com]:
Please enter your GitHub username: mhenrixon
Enter host password for user 'mhenrixon':

------------------------------------------------

ERROR: An API error occured.

Next up the second command

➜  user.workflow.703D3740-B1DA-4A10-A3F1-BF2BE8DF3838  cat "$HOME/Library/Application Support/Alfred 2/Workflow Data/pjkh.gist/config"
cat: /Users/mhenrixon/Library/Application Support/Alfred 2/Workflow Data/pjkh.gist/config: No such file or directory
phallstrom commented 10 years ago

Hrmph. Looks like they changed their setup so that if the token already exists on your github account it returns a failure. Go into https://github.com/settings/applications and remove all the access tokens for 'Gist for AlfredApp'. Then run setup normally (through alfred). Let me know if that fixes it and I'll update the docs and see if there's a work around.

kgust commented 10 years ago

I am seeing this same problem, with the same error, 'ERROR: An API error occured."

I went to https://github.com/settings/applications and didn't see 'Gist for AlfredApp'. Does it matter that I have 2 factor authentication turned on?

phallstrom commented 10 years ago

Ah... it very well might (I've never gotten around to using 2factor yet). Can you try running this from the terminal?

curl -v --user USERNAME https://api.github.com/authorizations

Replacing USERNAME with your github username. For me that will ask for my github password and then return all my authorizations in json format. Curious to know what it returns for you.

I may need to rewrite the setup to work with 2factor. I've been getting annoyed at shell/json interaction so maybe will just redo the whole thing in ruby. Heh.

Thanks!

kgust commented 10 years ago
curl -v --user kgust https://api.github.com/authorizations                                                                                                                         ⏎ ✭ ✚ ◼
Enter host password for user 'kgust':
* Adding handle: conn: 0x7fdc6b80aa00
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fdc6b80aa00) send_pipe: 1, recv_pipe: 0
* About to connect() to api.github.com port 443 (#0)
*   Trying 192.30.252.136...
* Connected to api.github.com (192.30.252.136) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
* Server certificate: *.github.com
* Server certificate: DigiCert High Assurance CA-3
* Server certificate: DigiCert High Assurance EV Root CA
* Server certificate: Entrust.net Secure Server Certification Authority
* Server auth using Basic with user 'kgust'
> GET /authorizations HTTP/1.1
> Authorization: Basic a2d1c3Q6Q2FsbDRpdCE=
> User-Agent: curl/7.30.0
> Host: api.github.com
> Accept: */*
>
< HTTP/1.1 401 Unauthorized
* Server GitHub.com is not blacklisted
< Server: GitHub.com
< Date: Sat, 08 Mar 2014 18:50:18 GMT
< Content-Type: application/json; charset=utf-8
< Status: 401 Unauthorized
< X-GitHub-OTP: required; app
< X-GitHub-Media-Type: github.beta
< X-Content-Type-Options: nosniff
< X-RateLimit-Limit: 60
< X-RateLimit-Remaining: 55
< X-RateLimit-Reset: 1394306218
< Content-Length: 169
< Access-Control-Allow-Credentials: true
< Access-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
< Access-Control-Allow-Origin: *
< X-GitHub-Request-Id: 180D9867:3BE0:806B62A:531B6669
<
{
  "message": "Must specify two-factor authentication OTP code.",
  "documentation_url": "http://developer.github.com/v3/auth#working-with-two-factor-authentication"
}
* Connection #0 to host api.github.com left intact
phallstrom commented 10 years ago

Yep. 2factor is the culprit. I'll see if I can work on a fix. If you're antsy, you could disable 2factor for a second, run setup, then put it back. Not ideal, but it would get you going.

phallstrom commented 10 years ago

@kgust @mhenrixon Would either of you have a problem if I rewrote this in Ruby requiring at least version 1.9 ?

mhenrixon commented 10 years ago

Not a problem at all for me. — Sent from Mailbox for iPhone

On Sat, Mar 8, 2014 at 8:17 PM, Philip Hallstrom notifications@github.com wrote:

@kgust @mhenrixon Would either of you have a problem if I rewrote this in Ruby requiring at least version 1.9 ?

Reply to this email directly or view it on GitHub: https://github.com/phallstrom/AlfredGist/issues/13#issuecomment-37106818

kgust commented 10 years ago

Not a problem for me either.

phallstrom commented 10 years ago

@kgust @mhenrixon So... turns out that since I wrote this github has made it possible to generate your own access tokens without having to do it via an api. Nifty. So I can skip the 2factor stuff and everything else and just change the setup to make you go create your own token and then add it to this workflow's configs.

I've changed the workflow so grab a new copy of it:

https://raw.github.com/phallstrom/AlfredGist/master/Gist.alfredworkflow

Then follow the setup instructions here:

https://github.com/phallstrom/AlfredGist#setup

I think this will solve your issues. I'm closing this ticket, but if I'm wrong about that, please comment and I'll open it back up.

kgust commented 10 years ago

I can confirm, this works.