Skip to content

Instantly share code, notes, and snippets.

@brianly
Last active December 14, 2015 11:38
Show Gist options
  • Save brianly/5080280 to your computer and use it in GitHub Desktop.
Save brianly/5080280 to your computer and use it in GitHub Desktop.
An example showing you how to get an Access Token with YamPy.
# -*- coding: utf-8 -*-
import os
import yampy
import webbrowser
# Configure all of these constants at https://www.yammer.com/client_applications
CLIENT_ID = ''
CLIENT_SECRET = ''
REDIRECT_URI = 'http://brianlyttle.com/yammer/'
def main():
# Get ready
authenticator = yampy.Authenticator(client_id=CLIENT_ID,
client_secret=CLIENT_SECRET)
# Setup a Redirect URI
auth_url = authenticator.authorization_url(redirect_uri=REDIRECT_URI)
# Open the authorization URL and capture the code from the URL
webbrowser.open(auth_url)
code = raw_input("Enter the code param from the URL: ")
# Exchange the code for an access token
access_token = authenticator.fetch_access_token(code)
print 'Access Token: %s' % access_token
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment