{"action":"closed","issue":{"url":"https://api.github.com/repos/joshsoftware/code-curiosity/issues/176","repository_url":"https://api.github.com/repos/joshsoftware/code-curiosity","labels_url":"https://api.github.com/repos/joshsoftware/code-curiosity/issues/176/labels{/name}","comments_url":"https://api.github.com/repos/joshsoftware/code-curiosity/issues/176/comments","events_url":"https://api.github.com/repos/joshsoftware/code-curiosity/issues/176/events","html_url":"https://github.com/joshsoftware/code-curiosity/issues/176","id":184796767,"number":176,"title":"User#refresh_gh_client raises ActiveSupport::MessageVerifier::InvalidSignature","user":{"login":"prasadsurase","id":562052,"avatar_url":"https://avatars.githubusercontent.com/u/562052?v=3","gravatar_id":"","url":"https://api.github.com/users/prasadsurase","html_url":"https://github.com/prasadsurase","followers_url":"https://api.github.com/users/prasadsurase/followers","following_url":"https://api.github.com/users/prasadsurase/following{/other_user}","gists_url":"https://api.github.com/users/prasadsurase/gists{/gist_id}","starred_url":"https://api.github.com/users/prasadsurase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prasadsurase/subscriptions","organizations_url":"https://api.github.com/users/prasadsurase/orgs","repos_url":"https://api.github.com/users/prasadsurase/repos","events_url":"https://api.github.com/users/prasadsurase/events{/privacy}","received_events_url":"https://api.github.com/users/prasadsurase/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-24T09:55:59Z","updated_at":"2016-10-25T05:56:13Z","closed_at":"2016-10-25T05:56:13Z","body":"The method [User#refresh_gh_client](https://github.com/joshsoftware/code-curiosity/blob/master/app/models/concerns/user_github_helper.rb#L18) sometimes raises **ActiveSupport::MessageVerifier::InvalidSignature** exception though not consistently. This is  because the [user's](https://github.com/joshsoftware/code-curiosity/blob/master/app/models/concerns/user_github_helper.rb#L19) auth_token is invalid and cannot be verified as done [here](https://github.com/joshsoftware/code-curiosity/blob/master/app/models/concerns/user_github_helper.rb#L20). This can be fixed as\r\n1) getting a user with valid auth_token\r\n\r\n```ruby\r\ndef refresh_gh_client                                                                                                           \r\n  auth_tk = nil                                                                                                                 \r\n  begin                                                                                                                         \r\n    u = User.where(:auth_token.ne => nil).all.sample                                                                            \r\n    auth_tk = User.encrypter.decrypt_and_verify(u.auth_token)                                                                   \r\n  rescue ActiveSupport::MessageVerifier::InvalidSignature\r\n    u.set({auth_token: nil})                                                              \r\n    retry                                                                                                                       \r\n  end                                                                                                                           \r\n  @gh_client = Github.new({                                                                                                     \r\n  oauth_token: auth_tk,                                                                                                       \r\n    client_id: ENV['GIT_APP_ID'],                                                                                               \r\n    client_secret: ENV['GIT_APP_SECRET']                                                                                        \r\n  })                                                                                                                            \r\nend\r\n```\r\n2) Refreshing the current user's auth_token.\r\nIdeas?"}}
{"actor":{"display_login":"prasadsurase"}}