API for Authentication

Hi, I’m having trouble using the Apiary listed API for getting authentication. I’ve looked through old forum posts about the topic and found that the listed API is out-of-date and that the current endpoint is /oauth2/token instead of /oauth2/access_token/ like listed on Apiary, but I am only getting a 405.

Here is the code producing this error:

import requests as rq

data = {		'username': 'username_redacted',
						'password': 'password_redacted',
						'client_id': 'id_has_been_redacted',
						'client_secret': 'secret_has_been_redacted',
						'grant_type': 'password'}
resp = rq.post(	'https://beta.online-go.com/oauth2/token', data=data )
print(resp)
print(resp.json())

The credentials I am providing are associated with the account I made the application with on the beta website, and the settings for that are:

* **Client type**public
* **Authorization Grant Type**client-credentials

Are these settings correct? Should they be changed? If they are correct, is there something I’m clearly doing wrong? I’m new to this, so I’m sorry if I missed another thread that has the solution.

And make sure you’re registered on the main site, not beta!

Incredible, thank you so much!

This doesn’t work when I try to modify my code to send the same info, but using the curl you posted in that thread, I do get a response, which means I’m doing something wrong on my end as well as having the issue you pointed out. That’s enough info for me to fix the rest on my own, I think.

I’ll post again when I have it working so the next person to search can find it before they need to ask.

1 Like

Here we go:

import requests as rq

data = {		'grant_type': 'password',
						'username': 'asdadsasd',
						'password': 'asdasdas',
						'client_id': 'asdasdasdasd' }
resp = rq.post(	'https://online-go.com/oauth2/token/', data=data)
print(resp.text)

gives out:

{"access_token": "EUy8ClWonvnKoG3YXyLp00nJ2n4lQL", "expires_in": 36000, "token_type": "Bearer", "scope": "read write groups", "refresh_token": "gjMhCaSbJcXgAJOzwwY9iVQkTqQItL"}

Thanks again!

1 Like

Bookmarking this thread for future reference.

I feel the whole API manual is outdated/incomplete. Is there a better source for this info?

I think looking at the code for Termsuji and for Rengo-bot is a decent substitution, because these do work currently (in my understanding). At least, I figured out the second half of my issue from looking at the Rengo-bot code.

2 Likes

Awesome! Thanks for posting the working script!

Yeahh… probably the forums have the most up-to-date info, just takes a little more digging

Oh, also notable, I couldn’t find the application manager from the main OGS website, only from the beta site. It has the same directory though, so it’s https://online-go.com/oauth2/applications for anyone who needs it.

1 Like