{"action":"created","issue":{"url":"https://api.github.com/repos/GoogleCloudPlatform/google-auth-library-python/issues/190","repository_url":"https://api.github.com/repos/GoogleCloudPlatform/google-auth-library-python","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/google-auth-library-python/issues/190/labels{/name}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/google-auth-library-python/issues/190/comments","events_url":"https://api.github.com/repos/GoogleCloudPlatform/google-auth-library-python/issues/190/events","html_url":"https://github.com/GoogleCloudPlatform/google-auth-library-python/issues/190","id":249779488,"number":190,"title":"'Credentials' object has no attribute 'authorize'","user":{"login":"Cosbgn","id":17546283,"avatar_url":"https://avatars3.githubusercontent.com/u/17546283?v=4","gravatar_id":"","url":"https://api.github.com/users/Cosbgn","html_url":"https://github.com/Cosbgn","followers_url":"https://api.github.com/users/Cosbgn/followers","following_url":"https://api.github.com/users/Cosbgn/following{/other_user}","gists_url":"https://api.github.com/users/Cosbgn/gists{/gist_id}","starred_url":"https://api.github.com/users/Cosbgn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cosbgn/subscriptions","organizations_url":"https://api.github.com/users/Cosbgn/orgs","repos_url":"https://api.github.com/users/Cosbgn/repos","events_url":"https://api.github.com/users/Cosbgn/events{/privacy}","received_events_url":"https://api.github.com/users/Cosbgn/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2017-08-12T01:21:37Z","updated_at":"2017-08-16T16:58:08Z","closed_at":"2017-08-14T16:17:46Z","body":"I'm migrating my app from the depriciated oAuth2Client to this library.\r\nI use `requests_oauthlib` to get the `refresh_token`, the `access_token` and all the rest.\r\nThen I build the `credential` object like this:\r\n\r\n```\r\n    credentials = google.oauth2.credentials.Credentials(\r\n                                                        access_token,\r\n                                                        refresh_token = refresh_token,\r\n                                                        token_uri = 'https://accounts.google.com/o/oauth2/token',\r\n                                                        client_id = settings.GOOGLE_CLIENT_ID,\r\n                                                        client_secret = settings.GOOGLE_CLIENT_SECRET\r\n                                                        )\r\n```\r\nI'm not sure about the `token_uri`, what am I supposed to put there?\r\nIn any case this seems to work, making a simple call like this one:\r\n```\r\n    authed_session = AuthorizedSession(credentials)\r\n    response = authed_session.get('https://www.googleapis.com/oauth2/v1/userinfo') \r\n```\r\nworks as expected and I do get back the results. \r\nHowever my app relies a lot on the Google Analytic api, which uses its own build method.\r\n\r\nWith oAuth2client I used to do (to get properties using v3):\r\n```\r\n    http = httplib2.Http()\r\n    http = credentials.authorize(http)\r\n    v3 = build('analytics', 'v3', http=http)\r\n    try:\r\n        account_summaries = v3.management().accountSummaries().list().execute()\r\n    except Exception as error:\r\n        return error_page(request, error)\r\n    google_email = account_summaries['username']\r\n```\r\nAnd to get metrics with v4:\r\n```\r\n    http = credentials.authorize(httplib2.Http())\r\n    DISCOVERY_URI = ('https://analyticsreporting.googleapis.com/$discovery/rest')\r\n    analytics = build('analytics', 'v4', http=http, discoveryServiceUrl=DISCOVERY_URI)\r\n```\r\nand then: `analytics.reports().batchGet( ...........etc)`\r\n\r\nHowever now that I migrate to this library I don't know how I can use the build method. All the documentation is really old and still referencing the depreciated library. How can I authenticate and use correctly google-auth with the Google Analytics API?\r\n\r\nThanks "},"comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/google-auth-library-python/issues/comments/322834857","html_url":"https://github.com/GoogleCloudPlatform/google-auth-library-python/issues/190#issuecomment-322834857","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/google-auth-library-python/issues/190","id":322834857,"user":{"login":"jonparrott","id":250995,"avatar_url":"https://avatars2.githubusercontent.com/u/250995?v=4","gravatar_id":"","url":"https://api.github.com/users/jonparrott","html_url":"https://github.com/jonparrott","followers_url":"https://api.github.com/users/jonparrott/followers","following_url":"https://api.github.com/users/jonparrott/following{/other_user}","gists_url":"https://api.github.com/users/jonparrott/gists{/gist_id}","starred_url":"https://api.github.com/users/jonparrott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonparrott/subscriptions","organizations_url":"https://api.github.com/users/jonparrott/orgs","repos_url":"https://api.github.com/users/jonparrott/repos","events_url":"https://api.github.com/users/jonparrott/events{/privacy}","received_events_url":"https://api.github.com/users/jonparrott/received_events","type":"User","site_admin":false},"created_at":"2017-08-16T16:58:08Z","updated_at":"2017-08-16T16:58:08Z","body":"@adamwilbert thanks, I just tried and I can't reproduce - just to be extra extra sure can you do:\r\n\r\n```python\r\nimport googleapiclient\r\nprint(googleapiclient.__version__)\r\n```"}}
{"actor":{"display_login":"jonparrott"}}