Authenticate with MoneyGram
Authenticate using SEP-10. Required information:
- User’s integer ID (positive, ≤64 bits).
- MoneyGram’s authentication endpoint:
- MoneyGram’s public key:
- Test: GCUZ6YLL5RQBTYLTTQLPCM73C5XAIUGK2TIMWQH7HPSGWVS2KJ2F3CHS
- Preview/Production: GD5NUMEX7LYHXGXCAD4PGW7JDMOUY2DKRGY5XZHJS5IONVHDKCJYGVCL
- Application’s authentication keypair.
Steps
- Request authentication challenge.
- MoneyGram provides challenge.
- Verify MoneyGram’s signature.
- Sign challenge with application’s key.
- Submit signed challenge.
- Receive session token.
import { Wallet, SigningKeypair } from "@stellar/typescript-wallet-sdk";
const wallet = Wallet.TestNet();
// Testnet
const MGI_ACCESS_HOST = "extstellar.moneygram.com";
// Mainnet
// const MGI_ACCESS_HOST = "stellar.moneygram.com";
// First we create an anchor object with MoneyGram's home domain.
const anchor = wallet.anchor({ homeDomain: MGI_ACCESS_HOST });
// Then we create the sep10 object which handles all the athentication steps.
const sep10 = await anchor.sep10();
// Finally, we authenticate using the wallet's SIGNING_KEY secret.
const authKey = SigningKeypair.fromSecret(AUTH_SECRET_KEY);
const authToken = await sep10.authenticate({ accountKp: authKey });
import requests
from stellar_sdk import Network
from stellar_sdk.sep.stellar_web_authentication import read_challenge_transaction
# Testnet
MGI_ACCESS_HOST = "extmgxanchor.moneygram.com"
# Pubnet
# MGI_ACCESS_HOST = "stellar.moneygram.com"
def get_token() -> str:
query = f"{AUTH_URL}?account={AUTH_PUBLIC_KEY}&memo={USER_ID}"
response = requests.get(query)
body = response.json()
challenge = read_challenge_transaction(
challenge_transaction=body["transaction"],
server_account_id=MGI_ACCESS_SIGNING_KEY,
home_domains=MGI_ACCESS_HOST,
web_auth_domain=MGI_ACCESS_HOST,
network_passphrase=Network.TESTNET_NETWORK_PASSPHRASE
)
challenge.transaction.sign(AUTH_SECRET_KEY)
post_body = {
"transaction": challenge.transaction.to_xdr()
}
response = requests.post(f"{AUTH_URL}", json=post_body)
response_body = response.json()
return response_body["token"]
Updated 9 days ago
What’s Next