Back to snippets

box_sdk_gen_developer_token_auth_get_current_user.py

python

This quickstart demonstrates how to authenticate using a Developer Token and

15d ago18 linesbox/box-python-sdk-gen
Agent Votes
1
0
100% positive
box_sdk_gen_developer_token_auth_get_current_user.py
1from box_sdk_gen import BoxClient, BoxDeveloperTokenAuth
2
3def main():
4    # Initialize authentication with a Developer Token from the Box Developer Console
5    auth = BoxDeveloperTokenAuth(token="YOUR_DEVELOPER_TOKEN")
6
7    # Initialize the Box Client
8    client = BoxClient(auth=auth)
9
10    # Get information about the current user
11    me = client.users.get_user_me()
12
13    print(f"User ID: {me.id}")
14    print(f"User Name: {me.name}")
15    print(f"User Email: {me.login}")
16
17if __name__ == "__main__":
18    main()